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

📄 fghack.c

📁 daemontools-0.76.tar.gz是在linux环境下自动监控进程的源程序
💻 C
字号:
#include <unistd.h>#include "wait.h"#include "error.h"#include "strerr.h"#include "buffer.h"#include "pathexec.h"#define FATAL "fghack: fatal: "int pid;int main(int argc,const char * const *argv,const char * const *envp){  char ch;  int wstat;  int pi[2];  int i;  if (!argv[1])    strerr_die1x(100,"fghack: usage: fghack child");  if (pipe(pi) == -1)    strerr_die2sys(111,FATAL,"unable to create pipe: ");  switch(pid = fork()) {    case -1:      strerr_die2sys(111,FATAL,"unable to fork: ");    case 0:      close(pi[0]);      for (i = 0;i < 30;++i)        dup(pi[1]);      pathexec_run(argv[1],argv + 1,envp);      strerr_die4sys(111,FATAL,"unable to run ",argv[1],": ");  }  close(pi[1]);  for (;;) {    i = buffer_unixread(pi[0],&ch,1);    if ((i == -1) && (errno == error_intr)) continue;    if (i == 1) continue;    break;  }  if (wait_pid(&wstat,pid) == -1)    strerr_die2sys(111,FATAL,"wait failed: ");  if (wait_crashed(wstat))    strerr_die2x(111,FATAL,"child crashed");  _exit(wait_exitcode(wstat));}

⌨️ 快捷键说明

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