--- src/main.c.orig	2011-03-30 19:31:12.000000000 +0200
+++ src/main.c	2011-04-12 01:38:01.000000000 +0200
@@ -40,6 +40,8 @@
 #include <sys/types.h>
 #include <sys/socket.h>
 
+#include <fcntl.h>
+
 #include "sispm_ctl.h"
 #include "socket.h"
 #include "main.h"
@@ -649,11 +651,22 @@
       	case 'l':
 	      {
       		int* s;
-	        if(verbose) printf("Server goes to listen mode now.\n");
-
-		      if( (s = socket_init(bindaddr)) != NULL)
+	        if(verbose)
+			{
+				printf("Server goes to listen mode now.\n");
+			}
+			if((s = socket_init(bindaddr)) != NULL)
+			{
+				daemonize();
 		        while(1)
+				{
         			l_listen(s,dev[devnum],devnum);
+				}
+			}
+			else
+			{
+				exit(EXIT_FAILURE);
+			}
     	    break;
   	    }
 #endif
@@ -692,6 +705,45 @@
   return;
 }
 
+#ifndef WEBLESS
+void daemonize()
+{
+	/* Our process ID and Session ID */
+	pid_t pid, sid;
+
+	/* Fork off the parent process */
+	pid = fork();
+	if (pid < 0) {
+		exit(EXIT_FAILURE);
+	}
+	/* If we got a good PID, then
+	   we can exit the parent process. */
+	if (pid > 0) {
+		exit(EXIT_SUCCESS);
+	}
+
+	/* Change the file mode mask */
+	umask(0);
+
+	/* Create a new SID for the child process */
+	sid = setsid();
+	if (sid < 0) {
+		/* Log the failure */
+		exit(EXIT_FAILURE);
+	}
+
+	/* Change the current working directory */
+	if ((chdir("/var/tmp")) < 0) {
+		/* Log the failure */
+		exit(EXIT_FAILURE);
+	}
+
+	/* Close out the standard file descriptors */
+	close(STDIN_FILENO);
+	close(STDOUT_FILENO);
+	close(STDERR_FILENO);
+}
+#endif
 
 int main(int argc, char** argv)
 {
