summaryrefslogtreecommitdiffstats
path: root/server.c
diff options
context:
space:
mode:
authorNicholas Marriott <nicholas.marriott@gmail.com>2007-10-04 11:52:03 +0000
committerNicholas Marriott <nicholas.marriott@gmail.com>2007-10-04 11:52:03 +0000
commit68a5d5c00be0e0445e72c2e960588d21c4494467 (patch)
treefa6e1bf24e1287633ff08a41d45d2c7f1e8ed24d /server.c
parentff56ed7bd66f9be56f525838c21695a8574c1a09 (diff)
Window attachment, malloc debugging, fix a segfault with no sessions.
Diffstat (limited to 'server.c')
-rw-r--r--server.c16
1 files changed, 9 insertions, 7 deletions
diff --git a/server.c b/server.c
index c6684ec4..fb033f87 100644
--- a/server.c
+++ b/server.c
@@ -1,4 +1,4 @@
-/* $Id: server.c,v 1.22 2007-10-04 00:02:10 nicm Exp $ */
+/* $Id: server.c,v 1.23 2007-10-04 11:52:03 nicm Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
@@ -62,7 +62,7 @@ server_start(char *path)
size_t sz;
pid_t pid;
mode_t mask;
- int fd, mode;
+ int n, fd, mode;
switch (pid = fork()) {
case -1:
@@ -74,6 +74,8 @@ server_start(char *path)
return (0);
}
+ xmalloc_clear();
+
logfile("server");
setproctitle("server (%s)", path);
log_debug("server started, pid %ld", (long) getpid());
@@ -103,15 +105,15 @@ server_start(char *path)
if (fcntl(fd, F_SETFL, mode|O_NONBLOCK) == -1)
fatal("fcntl failed");
- /*
- * Detach into the background. This means the PID changes which will
- * have to be fixed in some way at some point... XXX
- */
if (daemon(1, 1) != 0)
fatal("daemon failed");
log_debug("server daemonised, pid now %ld", (long) getpid());
- exit(server_main(path, fd));
+ n = server_main(path, fd);
+#ifdef DEBUG
+ xmalloc_report(getpid(), "server");
+#endif
+ exit(n);
}
/* Main server loop. */