tru64-unix-managers (formerly alpha-osf-managers) (1994-2012)
 help / color / mirror / Atom feed
From: ABDON TREMOLS <abdon.t () usa ! net>
To: tru64-unix-managers
Subject: SUMMARY wait funtion
Date: Tue, 18 Aug 1998 19:03:55 +0000	[thread overview]
Message-ID: <96078718211785.tru64-unix-managers.marc@archive.invalid> (raw)

Hello,

Thanks for your examples and suggestions, specially to 
( sorry if I forgot someone):

Kurt Carlson <snkac@java.sois.alaska.edu>
John Hascall <john@iastate.edu>
Larry Griffith <larry@garfield.wsc.mass.edu>
Lars Bro <lbr@dksin.dk>

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

                 reply	other threads:[~1998-08-18 19:03 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed
read-only archive

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox