LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   plz solve this fork program problem (https://www.linuxquestions.org/questions/programming-9/plz-solve-this-fork-program-problem-705560/)

ourtime545 02-18-2009 01:10 AM

plz solve this fork program problem
 
hi i have a question and i need its answer urgently so can u please answer me as fast as possible.

Here is a program that created 8 processes including the initial parent process.

Modify the program that would create 7 processes including the initial parent process.


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

main (void) {
int i;
printf("\n\nInitial Process \t PID %6d \t PPID %6d \t GID %6d\n\n", getpid(), getppid(), getpgid(0));
for(i=0; i<3; ++i)
if (fork() == 0)
printf("\n\nNew Process \t PID %6d \t PPID %6d \t GID %6d\n\n", getpid(), getppid(), getpgid(0));
}

unSpawn 02-18-2009 01:28 AM

Per the LQ Rules, please do not post homework assignments verbatim. We're happy to assist if you have specific questions or have hit a stumbling point, however. Let us know what you've already tried and what references you have used (including class notes, books, and Google searches) and we'll do our best to help. Also, keep in mind that your instructor might also be an LQ member.

ourtime545 02-18-2009 01:57 PM

Sorry for this . . .But i am new in Unix so i asked for help. I would appreciate if someone help me . And also this is my first post as u can see. I want to improve my unix knowledge so in future i can help other people who post their problem on this website

pixellany 02-18-2009 02:02 PM

I'm afraid you missed the point in the response above. Specifically:
Quote:

Let us know what you've already tried and what references you have used (including class notes, books, and Google searches) and we'll do our best to help
For starters, have you analyzed the code to determine how it creates 8 processes?

jlinkels 02-18-2009 07:54 PM

Quote:

Originally Posted by ourtime545 (Post 3448557)
Sorry for this . . .But i am new in Unix so i asked for help. I would appreciate if someone help me . And also this is my first post as u can see. I want to improve my unix knowledge so in future i can help other people who post their problem on this website

Sure... and you need urgent help and fast.

jlinkels


All times are GMT -5. The time now is 03:47 AM.