The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
Google UNIX.COM


Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts 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 High Level Programming 0 03-19-2008 04:44 AM
fork() with su (child with other user) heck High Level Programming 1 01-12-2007 05: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

Closed Thread
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
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 04:47 AM. Reason: added code tags
Forum Sponsor
  #2 (permalink)  
Old 03-19-2008
Part Time Moderator and Full Time Dad
 

Join Date: Sep 2006
Location: Rossem, Tazenda
Posts: 758
duplicate post, closing thread.
Google UNIX.COM
Closed Thread

Thread Tools
Display Modes




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


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

Content Relevant URLs by vBSEO 3.2.0