Welcome guest. Before posting on our computer help forum, you must register. Click here it's easy and free.

Author Topic: I need help  (Read 5218 times)

0 Members and 1 Guest are viewing this topic.

loveboy14

  • Guest
I need help
« on: November 25, 2004, 08:10:14 AM »
can anyone explain this programing codes?


proc1.c
#include <stdio.h>
int main()
{
int fork_return;
fork_return = fork();
printf("PID=%d, PPID=%d, fork_return=%d\n", getpid(), getppid
(), fork_return);
sleep(10); /* wait for 10 sec */
return 0;
}



proc2.c
#inlcude <stdio.h>
int main()
{
int chpid=fork();
if (chpid < 0)
{
printf("ERROR\n");
exit(1);
}
else if(chpid == 0)
{
printf("Child process: ");
printf("PID=%d, PPID=%d\n", getpid(), getppid());
sleep(10); /* waits 10 sec */
}
else
{
printf("Parent process: ");
printf("PID=%d, PPID=%d\n", getpid(), getppid());
sleep(10); /* waits 10 sec */
}
return 0;
}


R0c4

  • Guest
Re: I need help
« Reply #1 on: November 26, 2004, 12:00:53 AM »
Lol, I'm assuming your a college student, so I would recommend doing this yourself and ask your professor for infomation.

I would be glad help you, but I'm not going to solve this problem for you.  Is there a particular part of the code that you don't understand?  Point it out and I'll help you to the best of my abilities( I haven't worked with regular c for some time ).