Running the following code:
I would expect to see a single C in the output, and 1000 A's. Instead, I'm getting 72 C's and 3485 A's. This behavior makes no sense to me. Eventually, I plan to call execve from within the run_execve method, but do to the current problems, I've cut it out until I can get fork under control.Code:int run_execve ( int cid ); int so_far = 0; int MAX_PROCS = 1000; /* create this many processes */ int main(void) { int cid; printf ( "C\n" ); while ( so_far < MAX_PROCS ) { /* attempt to run an executable */ cid = fork(); run_execve ( cid ); printf ( "A\n" ); so_far++; } } int run_execve ( int cid ) { if ( cid == 0 ) { exit ( -1 ); } }



LinkBack URL
About LinkBacks


