Need help spawning a child

W. Lee Duncan duncan at dg-rtp.dg.com
Fri Jun 30 23:44:09 AEST 1989


In article <1661 at apt.UUCP> brian at apt.UUCP (Brian Litzinger) writes
of needing to creating asynchronous children and not having his
process table filled up.

Try orphaning your children (sounds mean, doesn't it).  Just do
something like:


void create_an_orphaned_process()
{
	int	pid1, pid2;


	if ((pid1 = fork()) < 0)
		end_all_life("no need to live");

	if (pid1 == 0) {

		/* the child -- it'll fork and die */

		if (pid2 = fork()) < 0)
			end_all_thought_of_life("why me");

		if (pid2 == 0) {
			exec("some grandchild program");
			end_all_sentient_life("shouldn't get here");
		} else
			exit(0);	/* the child is no longer needed */
	}

	return;	/* the original process goes on its merry way */

} /* end function */

>
><>  Brian Litzinger @ APT Technology Inc., San Jose, CA
><>  UUCP:  {apple,sun,pyramid}!daver!apt!brian    brian at apt.UUCP
><>  VOICE: 408 370 9077      FAX: 408 370 9291
>

--
W. Lee Duncan, Data General, RTP     - "How can you be two places at once
UUCP: {world}!mcnc!rti!dg-rtp!duncan -  when you're really no place at all?"
DOMAIN: duncan at dg-rtp.dg.com         -                Firesign Theatre



More information about the Comp.unix.questions mailing list