View Single Post
Old Oct 10th, 2004, 8:40 PM   #2
Sebeq
Programmer
 
Sebeq's Avatar
 
Join Date: Aug 2004
Location: Houston, Tx
Posts: 53
Rep Power: 5 Sebeq is on a distinguished road
Send a message via AIM to Sebeq Send a message via Yahoo to Sebeq
Quote:

#include <stdio.h>
#include <sys/types.h>
#include <unistd.h>

void main()
{
int i;
int n;
pid_t childpid;

for(i = 1; i < 4; ++i)
{
if((childpid = fork()) <= 0)
{
break;
}
}

fprintf(stderr, "This process %ld with parent %ld\n", (long)getpid(), (long)getppid());
}


Try it like this

#include <stdio.h>
#include <sys/types.h>
#include <unistd.h>

void main()
{
 int i;
 int n;
 pid_t childpid;

 for(i = 1; i < 4; ++i)
 {
  if((childpid = fork()) <= 0)) /*note that i put a ) at the end of the statement*/
  {
    break;
  }
 }

 fprintf(stderr, "This process %ld with parent %ld\n", (long)getpid(), (long)getppid());
}

Just remember if you have more than on "(" in a statement then you need to add 2 ))
at the end of it.
__________________
"I messured the landing in feet, and programmed it in meters, $1billion wHoOoOoPsSsSiE!!"
Sebeq is offline   Reply With Quote