UNIX Socket FAQ

A forum for questions and answers about network programming on Linux and all other Unix-like systems

You are not logged in.

#1 2007-10-24 05:12 PM

vishwajit
Member
Registered: 2007-10-24
Posts: 15

Re: Child process id 0

Can anyone tell me why child process id is zero after parent fork().

Offline

#2 2007-10-24 06:30 PM

jfriesne
Administrator
From: California
Registered: 2005-07-06
Posts: 348
Website

Re: Child process id 0

pid_t pid = fork();
if (pid < 0) perror("Fork failed!");
else if (pid > 0)
{
    // we are the parent process... do parent stuff
}
else
{
   // we are the child process... do child stuff
}

Offline

#3 2007-10-25 06:19 AM

vishwajit
Member
Registered: 2007-10-24
Posts: 15

Re: Child process id 0

Thanks for help

Offline

Board footer

Powered by FluxBB