[pisa-src] r1064 - trunk/libpisa

  • From: Thomas Jansen <mithi@xxxxxxxxx>
  • To: pisa-src@xxxxxxxxxxxxx
  • Date: Thu, 08 Oct 2009 17:57:49 +0200

Author: tjansen
Date: Thu Oct  8 17:57:49 2009
New Revision: 1064

Log:
pisa_daemonize: replace stdin, stdout, and stderr with /dev/null

Modified:
   trunk/libpisa/util.c

Modified: trunk/libpisa/util.c
==============================================================================
--- trunk/libpisa/util.c        Thu Oct  8 17:36:46 2009        (r1063)
+++ trunk/libpisa/util.c        Thu Oct  8 17:57:49 2009        (r1064)
@@ -1160,5 +1160,15 @@
        if (result > 0) /* parent is done, let the child do the rest */
                exit(0);
 
+       /* become a process group leader */
        setsid();
+
+       /* point stdin, stdout and stderr to /dev/null so we can't
+        * accidentially mess up a console */
+       close(0);
+       close(1);
+       close(2);
+       result = open("/dev/null", O_RDWR);
+       dup(result);
+       dup(result);
 }

Other related posts:

  • » [pisa-src] r1064 - trunk/libpisa - Thomas Jansen