--- shellinabox/shellinaboxd.c.orig	2012-04-21 19:30:44.000000000 +0200
+++ shellinabox/shellinaboxd.c	2012-12-27 18:45:33.000000000 +0100
@@ -1159,12 +1159,9 @@
   }
 
   if (demonize) {
-    pid_t pid;
-    check((pid             = fork()) >= 0);
-    if (pid) {
-      _exit(0);
+    if (daemon(0, 0) < 0) {
+   	  fatal("Failed to daemonize: %s", strerror(errno));
     }
-    setsid();
   }
   if (pidfile) {
 #ifndef O_LARGEFILE
