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, 02: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, 02:28 AM   #2
unSpawn
Moderator
 
Registered: May 2001
Posts: 27,666
Blog Entries: 54

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

Rep: Reputation: 729Reputation: 729Reputation: 729Reputation: 729Reputation: 729Reputation: 729Reputation: 729
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, 08:54 PM   #5
jlinkels
Senior Member
 
Registered: Oct 2003
Location: Bonaire
Distribution: Debian Wheezy/Jessie/Sid, Linux Mint DE
Posts: 4,234

Rep: Reputation: 545Reputation: 545Reputation: 545Reputation: 545Reputation: 545Reputation: 545
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 10:38 AM
Problem with fork() in cgi program klopfer Programming 6 03-30-2007 09:57 AM
linux shell program problem plz madhugp Programming 4 12-25-2006 11: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 12:20 PM
plz plz solve my route mapping problem nedian123 Linux - Networking 1 07-12-2004 10:41 PM


All times are GMT -5. The time now is 02:47 PM.

Main Menu
Advertisement
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