LinuxQuestions.org
Visit the LQ Articles and Editorials section
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices

Reply
 
Search this Thread
Old 02-18-2009, 01:10 AM   #1
ourtime545
LQ Newbie
 
Registered: Feb 2009
Posts: 2

Rep: Reputation: 0
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));
}
 
Old 02-18-2009, 01:28 AM   #2
unSpawn
Moderator
 
Registered: May 2001
Posts: 27,005
Blog Entries: 54

Rep: Reputation: 2763Reputation: 2763Reputation: 2763Reputation: 2763Reputation: 2763Reputation: 2763Reputation: 2763Reputation: 2763Reputation: 2763Reputation: 2763Reputation: 2763
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.
 
Old 02-18-2009, 01:57 PM   #3
ourtime545
LQ Newbie
 
Registered: Feb 2009
Posts: 2

Original Poster
Rep: Reputation: 0
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
 
Old 02-18-2009, 02:02 PM   #4
pixellany
LQ Veteran
 
Registered: Nov 2005
Location: Annapolis, MD
Distribution: Arch/XFCE
Posts: 17,802

Rep: Reputation: 728Reputation: 728Reputation: 728Reputation: 728Reputation: 728Reputation: 728Reputation: 728
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?
 
Old 02-18-2009, 07:54 PM   #5
jlinkels
Senior Member
 
Registered: Oct 2003
Location: Bonaire
Distribution: Debian Lenny/Squeeze/Wheezy/Sid
Posts: 4,053

Rep: Reputation: 484Reputation: 484Reputation: 484Reputation: 484Reputation: 484
Quote:
Originally Posted by ourtime545 View Post
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
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to implement a POSIX threaded program to solve producer/consumer problem cy163 Programming 3 09-13-2008 09:38 AM
Problem with fork() in cgi program klopfer Programming 6 03-30-2007 08:57 AM
linux shell program problem plz madhugp Programming 4 12-25-2006 10:53 AM
just 1 little problem to solve before I can run GTA III in wine plz help! vegetassj2 Linux - Games 2 04-27-2005 11:20 AM
plz plz solve my route mapping problem nedian123 Linux - Networking 1 07-12-2004 09:41 PM


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

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration