Fix incorrect check of return code from dup

This commit is contained in:
XinyuHou 2016-12-07 17:28:15 +00:00
parent 3b92a87261
commit 74d63df244
1 changed files with 3 additions and 1 deletions

View File

@ -117,9 +117,11 @@ ArchDaemonUnix::daemonize(const char* name, DaemonFunc func)
open("/dev/null", O_RDWR); open("/dev/null", O_RDWR);
int dupErr = dup(1); int dupErr = dup(1);
if (dupErr)
if (dupErr < 0) {
// NB: file logging actually isn't working at this point! // NB: file logging actually isn't working at this point!
LOG((CLOG_ERR "dup error: %i", dupErr)); LOG((CLOG_ERR "dup error: %i", dupErr));
}
#ifdef __APPLE__ #ifdef __APPLE__
return execSelfNonDaemonized(); return execSelfNonDaemonized();