X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ian/git?p=secnet.git;a=blobdiff_plain;f=log.c;h=cbe4a85bf013fd8d2c432ba510b1f9ac301bb1d6;hp=156f3549df18c23c481cc017f587ea96b475be79;hb=2d7478f775f7e150f46f095e8e4db90f24b362b8;hpb=f1393100aa5412f0df5ee363c6bdd42b2465fa59 diff --git a/log.c b/log.c index 156f354..cbe4a85 100644 --- a/log.c +++ b/log.c @@ -225,6 +225,23 @@ void lg_perror(struct log_if *lg, const char *desc, struct cloc *loc, va_end(al); } +void lg_exitstatus(struct log_if *lg, const char *desc, struct cloc *loc, + int class, int status, const char *progname) +{ + if (!status) + lg_perror(lg,desc,loc,class,0,"%s exited",progname); + else if (WIFEXITED(status)) + lg_perror(lg,desc,loc,class,0,"%s exited with error exit status %d", + progname,WEXITSTATUS(status)); + else if (WIFSIGNALED(status)) + lg_perror(lg,desc,loc,class,0,"%s died due to fatal signal %s (%d)%s", + progname,strsignal(WTERMSIG(status)),WTERMSIG(status), + WCOREDUMP(status)?" (core dumped)":""); + else + lg_perror(lg,desc,loc,class,0,"%s died with unknown wait status %d", + progname,status); +} + struct log_if *init_log(list_t *ll) { int i=0; @@ -562,6 +579,7 @@ static void log_from_fd_afterpoll(void *sst, struct pollfd *fds, int nfds) i=-1; } } + } else if (errno==EINTR || iswouldblock(errno)) { } else { Message(M_WARNING,"log_from_fd: %s\n",strerror(errno)); st->finished=True; @@ -581,6 +599,8 @@ void log_from_fd(int fd, cstring_t prefix, struct log_if *log) st->i=0; st->finished=False; + setnonblock(st->fd); + register_for_poll(st,log_from_fd_beforepoll,log_from_fd_afterpoll, prefix); }