On Wed, Apr 8, 2009 at 10:47 AM, Tyler Littlefield <ty...@tysdomain.com> wrote:

> you said that the parent process returns 0. so wouldn't it be:
> if (fork())
> {
> //child
> }
> else
> {
> //parent
> }

No, the parent gets back the PID of the child process (or -1 if there
is a failed fork), and the child process will return 0.

from the fork(2) man page:

 On success, the PID of the child process is returned  in  the  parent’s
       thread  of execution, and a 0 is returned in the child’s thread of exe-
       cution.  On failure, a -1 will be returned in the parent’s context,  no
       child process will be created, and errno will be set appropriately.

-- Brett
------------------------------------------------------------
"In the rhythm of music a secret is hidden;
    If I were to divulge it, it would overturn the world."
               -- Jelaleddin Rumi


------------------------------------

To unsubscribe, send a blank message to 
<mailto:c-prog-unsubscr...@yahoogroups.com>.Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/c-prog/

<*> Your email settings:
    Individual Email | Traditional

<*> To change settings online go to:
    http://groups.yahoo.com/group/c-prog/join
    (Yahoo! ID required)

<*> To change settings via email:
    mailto:c-prog-dig...@yahoogroups.com 
    mailto:c-prog-fullfeatu...@yahoogroups.com

<*> To unsubscribe from this group, send an email to:
    c-prog-unsubscr...@yahoogroups.com

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/

Reply via email to