anyone with better explanation ??.it's still not clear to me :(
--
Amol Sharma
Third Year Student
Computer Science and Engineering
MNNIT Allahabad
http://gplus.to/amolsharma99
http://twitter.com/amolsharma99http://in.linkedin.com/pub/amol-sharma/21/79b/507http://youtube.com/amolsharma99
similar question...also gives segmentation fault...plz explain...
http://ideone.com/nlpzT
#includeunistd.h#includefcntl.h#includestdio.h
int main()
{
int pid;
printf
http://www.opengroup.org/onlinepubs/009695399/functions/printf.html(Parent\n);
pid = vfork();
Both share the same address space that includes even the stack
The child *returns first clearing the stack.*Now when the parent process
tries to return the child process had already cleared the stack.SO it no
longer belongs to the parent process,so sigsegv.
Try with gdb dissassemble and
thnx saurabh.u rock :)
--
Amol Sharma
Third Year Student
Computer Science and Engineering
MNNIT Allahabad
http://gplus.to/amolsharma99
http://twitter.com/amolsharma99http://in.linkedin.com/pub/amol-sharma/21/79b/507http://youtube.com/amolsharma99
On Sat, Oct 1, 2011 at 4:55 PM, saurabh
hi it gives that
in fun1:incompatible implicit declaration of built-in function ‘printf’
in fun2:incompatible implicit declaration of built-in function ‘printf’
On Wed, Sep 21, 2011 at 7:37 AM, saurabh singh saurab...@gmail.com wrote:
#includesys/types.h
int fun1()
{
@sreeu :lol #includestdio.h? :P include this header file:P
That s not saurabh s question
On Wed, Sep 21, 2011 at 4:51 PM, SREENU NAIK srinivasulunai...@gmail.comwrote:
hi it gives that
in fun1:incompatible implicit declaration of built-in function ‘printf’
in fun2:incompatible implicit
Read this documentation
http://pubs.opengroup.org/onlinepubs/7908799/xsh/vfork.html
vfork creates read-only copy of the parent. You cannot call function or
assign value to variable except pid_t. Use fork and it should succeed.
PS: Please ask questions related to Algorithms, as it is algorithm
#includesys/types.h
int fun1()
{
if(vfork()==0);
else printf(Fun1\n);
}
int fun2()
{
printf(Fun2\n);
}
int main()
{
fun1();
fun2();
return 0;
}
Why does this program giving seg fault.?
--
Saurabh Singh
B.Tech