pidwait.c

来自「<B>Digital的Unix操作系统VAX 4.2源码</B>」· C语言 代码 · 共 46 行

C
46
字号
/* pidwait.c - wait for child to exit */#include "../h/mh.h"#include <signal.h>#include <stdio.h>#ifdef	BSD42#include <sys/wait.h>#endif	BSD42int     pidwait (id, sigsok)register int     id,		 sigsok;{    register int    pid;    TYPESIG (*hstat) (), (*istat) (), (*qstat) (), (*tstat) ();#ifndef	BSD42    int     status;#else	BSD42    union wait status;#endif	BSD42    if (sigsok == NOTOK) {	hstat = signal (SIGHUP, SIG_IGN);	istat = signal (SIGINT, SIG_IGN);	qstat = signal (SIGQUIT, SIG_IGN);	tstat = signal (SIGTERM, SIG_IGN);    }    while ((pid = wait (&status)) != NOTOK && pid != id)	continue;    if (sigsok == NOTOK) {	(void) signal (SIGHUP, hstat);	(void) signal (SIGINT, istat);	(void) signal (SIGQUIT, qstat);	(void) signal (SIGTERM, tstat);    }#ifndef	BSD42    return (pid == NOTOK ? NOTOK : status);#else	BSD42    return (pid == NOTOK ? NOTOK : status.w_status);#endif	BSD42}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?