RE: [LIP] fork()...

"Uday K Verma" <udayv-sA5OA4KG+12fsxuIvKNZIgC/[email protected]>
Newsgroups gmane.user-groups.linux.india.programmers
Message-ID <[email protected]>
So that you could determine whether you are in the child or the parent
process.

if (!fork ()) {
	/* this is the code that the child is supposed to run, use getpid to
get the process id */
	/* you would proabably want to exec something here */
}
/* parent code runs here */

At fork a new child process is created with exactly the same process image
as the parent, now the only way to tell whether you are a child or parent
process is by examining the return code from fork. In the child process it
returns 0 and in the parent process it returns the childs process id.

$ man 3 fork


Uday K Verma 

-----Original Message-----
From: linux-india-programmers-admin-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org
[mailto:linux-india-programmers-admin-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org] On Behalf Of
Sameer Oak
Sent: Wednesday, April 21, 2004 08:59 AM
To: linux-india-programmers-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org
Subject: [LIP] fork()...


why does a fork() system call return 0 to the newly created child process?
-
sameer oak.

*********************************************************
Disclaimer:          

This message (including any attachments) contains confidential information
intended for a specific individual and purpose, and is protected by law. 
If you are not the intended recipient, you should delete this message and
are hereby notified that any disclosure, copying, or distribution of this
message, or the taking of any action based on it, is strictly prohibited.

*********************************************************
Visit us at http://www.mahindrabt.com



-------------------------------------------------------
This SF.Net email is sponsored by: IBM Linux Tutorials Free Linux tutorial
presented by Daniel Robbins, President and CEO of GenToo technologies. Learn
everything from fundamentals to system
administration.http://ads.osdn.com/?ad_id=1470&alloc_id=3638&op=click
_______________________________________________
linux-india-programmers mailing list
linux-india-programmers-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org
https://lists.sourceforge.net/lists/listinfo/linux-india-programmers



-------------------------------------------------------
This SF.Net email is sponsored by: IBM Linux Tutorials
Free Linux tutorial presented by Daniel Robbins, President and CEO of
GenToo technologies. Learn everything from fundamentals to system
administration.http://ads.osdn.com/?ad_id=1470&alloc_id=3638&op=click
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.