From a1e3efc3c486b32725ec7922aea9d8757fb169b3 Mon Sep 17 00:00:00 2001 From: Joachim Nilsson Date: Wed, 23 Oct 2019 12:48:23 +0200 Subject: [PATCH] Refactor differences in signal sent from UNIX/Linux kernel on hangup Signed-off-by: Joachim Nilsson --- src/syslogd.c | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/src/syslogd.c b/src/syslogd.c index 30a3450..8b4be2a 100644 --- a/src/syslogd.c +++ b/src/syslogd.c @@ -570,6 +570,15 @@ static char sccsid[] __attribute__((unused)) = #include "config.h" #include +/* + * Linux uses EIO instead of EBADFD (mrn 12 May 96) + */ +#ifdef linux +#define EHANGUP EIO +#else +#define EHANGUP EBADFD +#endif + #ifndef UTMP_FILE #ifdef UTMP_FILENAME #define UTMP_FILE UTMP_FILENAME @@ -2165,15 +2174,9 @@ void fprintlog(struct filed *f, char *from, int flags, char *msg) (void)close(f->f_file); /* - * Check for EBADF on TTY's due to vhangup() XXX - * Linux uses EIO instead (mrn 12 May 96) + * Check for EBADF/EIO on TTY's due to vhangup() */ - if ((f->f_type == F_TTY || f->f_type == F_CONSOLE) -#ifdef linux - && e == EIO) { -#else - && e == EBADF) { -#endif + if ((f->f_type == F_TTY || f->f_type == F_CONSOLE) && e == EHANGUP) { f->f_file = open(f->f_un.f_fname, O_WRONLY | O_APPEND | O_NOCTTY); if (f->f_file < 0) { f->f_type = F_UNUSED;