server.c
changeset 263 0d831e6cf8ef
parent 260 ecd09b351170
child 267 11631dd11ff8
--- a/server.c	Sun Feb 15 19:12:32 2009 +0100
+++ b/server.c	Sun Feb 15 21:28:08 2009 +0100
@@ -19,6 +19,7 @@
 #include <limits.h>
 #include <signal.h>
 #include <fcntl.h>
+#include <libgen.h>
 
 #include <stdio.h>
 
@@ -151,12 +152,18 @@
     int ls;
     struct sockaddr_un addr;
     int res;
+    char *dirpath;
 
     process_type = SERVER;
     max_descriptors = get_max_descriptors();
 
     path = _path;
 
+    /* Move the server to the socket directory */
+    dirpath = strdup(path);
+    chdir(dirname(dirpath));
+    free(dirpath);
+
     nconnections = 0;
 
     ls = socket(AF_UNIX, SOCK_STREAM, 0);