Mercurial > hg > Applications > mh
view sbr/pidwait.c @ 3:f89a9a79e124
utf-8
author | kono |
---|---|
date | Wed, 20 Apr 2005 00:25:01 +0900 |
parents | bce86c4163a3 |
children | 441a2190cfae |
line wrap: on
line source
/* pidwait.c - wait for child to exit */ #ifndef lint static char ident[] = "@(#)$Id$"; #endif /* lint */ #include "../h/mh.h" #include <signal.h> #include <stdio.h> #if defined (BSD42) || defined (SVR4) #include <sys/wait.h> #endif int pidwait (id, sigsok) register int id, sigsok; { register int pid; TYPESIG (*hstat) (), (*istat) (), (*qstat) (), (*tstat) (); #if defined(BSD42) && !defined(WAITINT) union wait status; #else int status; #endif if (sigsok == NOTOK) { #ifdef notdef /* I don't see why to trap these... */ hstat = signal (SIGHUP, SIG_IGN); tstat = signal (SIGTERM, SIG_IGN); #endif istat = signal (SIGINT, SIG_IGN); qstat = signal (SIGQUIT, SIG_IGN); } #ifdef SVR4 pid = waitpid (id, &status, WUNTRACED); #else while ((pid = wait (&status)) != NOTOK && pid != id) continue; #endif if (sigsok == NOTOK) { #ifdef notdef (void) signal (SIGHUP, hstat); (void) signal (SIGTERM, tstat); #endif (void) signal (SIGINT, istat); (void) signal (SIGQUIT, qstat); } #if defined(BSD42) && !defined(WAITINT) return (pid == NOTOK ? NOTOK : status.w_status); #else return (pid == NOTOK ? NOTOK : status); #endif }