chiark / gitweb /
Import release 0.1.9
[secnet.git] / secnet.c
index c7ce2b8a459b6707431b11e2bd182e637035a6c1..57b4f052074d8a471c4936cd8b4952d3407f9759 100644 (file)
--- a/secnet.c
+++ b/secnet.c
@@ -342,6 +342,10 @@ static void droppriv(void)
        } else if (p==0) {
            /* Child process - all done, just carry on */
            if (pf) fclose(pf);
+           /* Close stdin, stdout and stderr; we don't need them any more */
+           close(0);
+           close(1);
+           close(2);
            secnet_is_daemon=True;
        } else {
            /* Error */
@@ -388,11 +392,11 @@ int main(int argc, char **argv)
     enter_phase(PHASE_DROPPRIV);
     droppriv();
 
-    enter_phase(PHASE_RUN);
     start_signal_handling();
     request_signal_notification(SIGTERM,finish,"SIGTERM");
     if (!background) request_signal_notification(SIGINT,finish,"SIGINT");
     request_signal_notification(SIGHUP,ignore_hup,NULL);
+    enter_phase(PHASE_RUN);
     run();
 
     enter_phase(PHASE_SHUTDOWN);