From 027a73a903af306449710ce12bc09e0e3550c6c9 Mon Sep 17 00:00:00 2001 From: Rob Landley Date: Thu, 4 Aug 2016 10:16:59 -0500 Subject: Make xopen() skip stdin/stdout/stderr, add xopen_stdio() if you want stdout, add xopenro() that takes one argument and understands "-" means stdin, and switch over lots of users. --- toys/pending/crond.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'toys/pending/crond.c') diff --git a/toys/pending/crond.c b/toys/pending/crond.c index 1b5e4194..df8b5f11 100644 --- a/toys/pending/crond.c +++ b/toys/pending/crond.c @@ -79,10 +79,11 @@ static void loginfo(uint8_t loglevel, char *msg, ...) if (!TT.flagd && TT.logfile) { int fd = open(TT.logfile, O_WRONLY | O_CREAT | O_APPEND, 0666); - if (fd >=0 && fd != 2) { + if (fd==-1) perror_msg("'%s", TT.logfile); + else { dup2(fd, 2); close(fd); - } else if (fd < 0) perror_msg("'%s", TT.logfile); + } } used = vsnprintf(NULL, 0, msg, d); smsg = xzalloc(++used); -- cgit v1.2.3