chiark / gitweb /
slip: Report unexpected kinds of death from userv
[secnet.git] / slip.c
diff --git a/slip.c b/slip.c
index d8b32d8dbda79b5ad8ad4432be2adb4d3a166a10..3f7935a008ad16e483a3aaee72af8795b033147a 100644 (file)
--- a/slip.c
+++ b/slip.c
@@ -170,13 +170,13 @@ static int userv_beforepoll(void *sst, struct pollfd *fds, int *nfds_io,
     struct userv *st=sst;
 
     if (st->rxfd!=-1) {
-       *nfds_io=2;
+       BEFOREPOLL_WANT_FDS(2);
        fds[0].fd=st->txfd;
        fds[0].events=0; /* Might want to pick up POLLOUT sometime */
        fds[1].fd=st->rxfd;
        fds[1].events=POLLIN;
     } else {
-       *nfds_io=0;
+       BEFOREPOLL_WANT_FDS(0);
     }
     return 0;
 }
@@ -230,20 +230,13 @@ static void userv_userv_callback(void *sst, pid_t pid, int status)
                "(expected %d)\n",pid,st->pid);
        return;
     }
-    if (!st->expecting_userv_exit) {
-       if (WIFEXITED(status)) {
-           fatal("%s: userv exited unexpectedly with status %d",
-                 st->slip.nl.name,WEXITSTATUS(status));
-       } else if (WIFSIGNALED(status)) {
-           fatal("%s: userv exited unexpectedly: uncaught signal %d",
-                 st->slip.nl.name,WTERMSIG(status));
-       } else {
-           fatal("%s: userv stopped unexpectedly",
-                 st->slip.nl.name);
-       }
+    if (!(st->expecting_userv_exit &&
+         (!status ||
+          (WIFSIGNALED(status) && WTERMSIG(status)==SIGTERM)))) {
+       lg_exitstatus(0,st->slip.nl.name,0,
+                     st->expecting_userv_exit ? M_WARNING : M_FATAL,
+                     status,"userv");
     }
-    Message(M_WARNING,"%s: userv subprocess died with status %d\n",
-           st->slip.nl.name,WEXITSTATUS(status));
     st->pid=0;
 }
 
@@ -391,7 +384,7 @@ static void userv_phase_hook(void *sst, uint32_t newphase)
     if (newphase==PHASE_RUN) {
        userv_invoke_userv(st);
        /* Register for poll() */
-       register_for_poll(st, userv_beforepoll, userv_afterpoll, 2,
+       register_for_poll(st, userv_beforepoll, userv_afterpoll,
                          st->slip.nl.name);
     }
     if (newphase==PHASE_SHUTDOWN) {