putting C programs in the background

Sam Kendall kendall at talcott.UUCP
Mon Jan 21 05:24:52 AEST 1985


> >To put a C program in the background . . . .
> 
> Almost.  Actually, a little too simple.  Better:
> 
> 	pid = fork();
> 	if( pid < 0 )
> 	{
> 	    /* Print error message */
> 	    exit(1);
> 	}
> 	else if( pid > 0 )
> 	{
> 	    /* parent */
> 	    exit(0);
> 	}
> 	/* else pid == 0, this is the child.  Continue */

Those "exit" calls should be "_exit", to avoid duplication of
buffered output.

	Sam Kendall	  {allegra,ihnp4,ima,amd}!wjh12!kendall
	Delft Consulting Corp.	    decvax!genrad!wjh12!kendall



More information about the Comp.lang.c mailing list