From 1dbe2fe17f5907dae94c292e46c99299d13cbe34 Mon Sep 17 00:00:00 2001 From: brain Date: Fri, 20 Apr 2007 16:37:37 +0000 Subject: Fix for "hanging" when controlling terminal is not a tty (nofork check and isatty checks lumped together by mistake) git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@6818 e03df62e-2008-0410-955e-edbf42e46eb7 --- src/inspircd.cpp | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/inspircd.cpp b/src/inspircd.cpp index 6aa6c9519..bacd92961 100644 --- a/src/inspircd.cpp +++ b/src/inspircd.cpp @@ -463,18 +463,21 @@ InspIRCd::InspIRCd(int argc, char** argv) } } - if (!Config->nofork && isatty(0) && isatty(1) && isatty(2)) + if (!Config->nofork) { - /* We didn't start from a TTY, we must have started from a background process - - * e.g. we are restarting, or being launched by cron. Dont kill parent, and dont - * close stdin/stdout - */ if (kill(getppid(), SIGTERM) == -1) { printf("Error killing parent process: %s\n",strerror(errno)); Log(DEFAULT,"Error killing parent process: %s",strerror(errno)); } + } + if (isatty(0) && isatty(1) && isatty(2)) + { + /* We didn't start from a TTY, we must have started from a background process - + * e.g. we are restarting, or being launched by cron. Dont kill parent, and dont + * close stdin/stdout + */ fclose(stdin); fclose(stderr); fclose(stdout); -- cgit v1.2.3