-}
-
-static void sl_entry(void) {
- mdup2(slpipe[1],1,"slattach child");
- execlp("slattach", "slattach", "-v", "-L", "-p",proto, ptyname, (char*)0);
- sysfatal("cannot exec slattach");
-}
-
-static void cin_entry(void) {
- mdup2(ptmaster,1,"cat input child");
- execlp("cat", "cat", (char*)0);
- sysfatal("cannot exec cat input");
-}
-
-static void cout_entry(void) {
- mdup2(ptmaster,0,"cat output child");
- execlp("cat", "cat", (char*)0);
- sysfatal("cannot exec cat output");
-}
-
-static void sighandler(int signum) {
- pid_t pid;
- int estatus, status;
- const char *taskfail;
-
- estatus= 4;
-
- if (signum == SIGCHLD) {
- for (;;) {
- pid= waitpid(-1,&status,WNOHANG);
- if (!pid || pid == (pid_t)-1) return;
-
- if (pid == pids.byname.task) {
- pids.byname.task= 0;
- if (!status) return;
- taskfail= "task";
- } else if (pid == pids.byname.cin) {
- pids.byname.cin= 0;
- if (status) {
- taskfail= "input cat";
- } else {
- taskfail= 0;
- estatus= 0;
- }
- } else if (pid == pids.byname.cout) {
- pids.byname.cout= 0;
- taskfail= "output cat";
- } else if (pid == pids.byname.sl) {
- pids.byname.sl= 0;
- taskfail= "slattach";
- } else {
- continue;
- }
- break;
- }
- if (taskfail) {
- if (WIFEXITED(status)) {
- fprintf(stderr,
- "userv-ipif service: %s unexpectedly exited with exit status %d\n",
- taskfail, WEXITSTATUS(status));
- } else if (WIFSIGNALED(status)) {
- fprintf(stderr,
- "userv-ipif service: %s unexpectedly killed by signal %s%s\n",
- taskfail, strsignal(WTERMSIG(status)),
- WCOREDUMP(status) ? " (core dumped)" : "");
- } else {
- fprintf(stderr, "userv-ipif service: %s unexpectedly terminated"
- " with unknown status code %d\n", taskfail, status);
- }
- }
+ assert(pidr==pid);
+
+ if (WIFEXITED(status)) {
+ if (WEXITSTATUS(status))
+ fatal("userv-ipif service: %s exited with error exit status %d\n",
+ desc, WEXITSTATUS(status));
+ } else if (WIFSIGNALED(status)) {
+ fatal("userv-ipif service: %s died due to signal %s%s\n",
+ desc, strsignal(WTERMSIG(status)),
+ WCOREDUMP(status) ? " (core dumped)" : "");