⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 waitpid.c

📁 java 到c的转换程序的原代码.对喜欢C程序而不懂JAVA程序的人很有帮助
💻 C
字号:
/* Routine to handle blocking waits using conditions, signals, and * non-blocking waits. This prevent the entire system from freezing * when wait() is called. */#include <sys/types.h>#include <sys/wait.h>#include <errno.h>#include "scout_semaphore.h"struct Semaphore waitSema;pid_t__wrap_waitpid(pid_t pid, int *status, int options){    int ret;    if ((options & WNOHANG) != 0) {	return __real_waitpid(pid, status, options);    } else {	while ((ret = __real_waitpid(pid, status, (options | WNOHANG))) == 0) {	    /* There are no children ready to be waited on, so 	     * wait on a semaphore that SIGCHLD will broadcast. */	    semaphoreWait(&waitSema);	}	return ret;    }}voidwaitSignal() {    semaphoreSignalAll(&waitSema);}voidwaitInit() {    semaphoreInit(&waitSema, 0);}

⌨️ 快捷键说明

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