From mboxrd@z Thu Jan 1 00:00:00 1970 Message-ID: <96078718211785.tru64-unix-managers.marc@archive.invalid> From: ABDON TREMOLS Date: Tue, 18 Aug 1998 19:03:55 +0000 To: tru64-unix-managers Subject: SUMMARY wait funtion X-MARC-Message: https://marc.info/?l=tru64-unix-managers&m=96078718211785 Hello, Thanks for your examples and suggestions, specially to ( sorry if I forgot someone): Kurt Carlson John Hascall Larry Griffith Lars Bro The general idea is to get a copy of Unix Network Programing by W. Richard Stevens. This is a listing of one of the examples I received: pid_t cpid; pid_t wpid; int wst; extern int errno; switch (cpid = fork()) { case -1: /* error */ fprintf(stderr, "fork failed: %s\n", strerror(errno)); exit(1); case 0: /* child (new process) */ execl("/bin/ps", "ps", "ax", NULL); fprintf(stderr, "exec failed: %s\n", strerror(errno)); exit(1); default: /* parent (original proc) */ while ((wpid = wait(&wst)) != -1) { if (wpid == cpid) { /* child just started above died */ break; } else { /* some other child died??? */ } /* could use WIFEXITED/WEXITSTATUS/etc here to * look at child's exit status in 'wst' variable * (see "man wait" for details) */ } } Thanks again, Abdon ____________________________________________________________________ Get free e-mail and a permanent address at http://www.netaddress.com/?N=1