The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > High Level Programming
Google UNIX.COM


High Level Programming Post questions about C, C++, Java, SQL, and other programming languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Problems with child comunicating with parent on fork() Zarnick High Level Programming 8 05-06-2008 09:35 AM
fork() and child processes green_dot Shell Programming and Scripting 1 03-19-2008 05:49 AM
fork() with su (child with other user) heck High Level Programming 1 01-12-2007 06:58 AM
Parent/Child Processes yoi2hot4ya Shell Programming and Scripting 2 05-31-2006 10:27 AM
Reference Variables To A Child Process Created With Fork AJAY BHATIA High Level Programming 2 10-07-2001 05:41 PM

Reply
 
Submit Tools LinkBack Thread Tools Search this Thread Display Modes
  #1  
Old 03-19-2008
Registered User
 

Join Date: Mar 2008
Posts: 2
fork() and child processes

Hello,

How many child processes are actually created when running this code ?

Code:
#include <signal.h>
#include <stdio.h>

int main () {
int i ;
setpgrp () ;
for (i = 0; i < 10; i++) {
if (fork () == 0) {
if ( i & 1 ) setpgrp () ;
printf ("Child id: %2d, group: %2d\n", getpid(), getpgrp()) ;
sleep (60) ;
exit (0) ;
}
}
kill (0, SIGINT) ;
return 0 ;
}

Last edited by Yogesh Sawant; 03-19-2008 at 05:50 AM. Reason: added code tags
Reply With Quote
Google The UNIX and Linux Forums
Forum Sponsor
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes




All times are GMT -7. The time now is 12:30 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008. All Rights Reserved.Ad Management by RedTyger Visit The Complex Event Processing Blog

Content Relevant URLs by vBSEO 3.2.0