Children's exit() status

Paul Placeway paul at morganucodon.cis.ohio-state.edu
Tue Jun 14 04:17:54 AEST 1988


In article <10105 at mcdchg.UUCP> daveb at laidbak.UUCP (Dave Burton) writes:
< Actually, this is more effort than is required.
< wait(2) will return a -1 and set errno to ECHILD if there are no more
< children to wait() on. So a simple loop will work:
< 
< 	while (wait(&status) != -1 || errno != ECHILD)
< 		;	/* check status here if desired */

Ah yes, but what if you want to catch all of your exited children, you
might still have running children, and you _don't_ want to wait(2) for
them too?  Under BSD you could do that as:

	while (wait3(&status, WNOHANG, NULL) != -1 || errno != ECHILD) {
		/* stuff */
	}

But what about USG?

		--Paul



More information about the Comp.unix mailing list