tellwait.c
来自「unix环境高级编程 配套源代码 学习学习啊」· C语言 代码 · 共 47 行
C
47 行
#include "ourhdr.h"static int pfd1[2], pfd2[2];voidTELL_WAIT(){ if (pipe(pfd1) < 0 || pipe(pfd2) < 0) err_sys("pipe error");}voidTELL_PARENT(pid_t pid){ if (write(pfd2[1], "c", 1) != 1) err_sys("write error");}voidWAIT_PARENT(void){ char c; if (read(pfd1[0], &c, 1) != 1) err_sys("read error"); if (c != 'p') err_quit("WAIT_PARENT: incorrect data");}voidTELL_CHILD(pid_t pid){ if (write(pfd1[1], "p", 1) != 1) err_sys("write error");}voidWAIT_CHILD(void){ char c; if (read(pfd2[0], &c, 1) != 1) err_sys("read error"); if (c != 'c') err_quit("WAIT_CHILD: incorrect data");}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?