From a26f58c7c394f81c523da597f85f69d3fc8bc8ad Mon Sep 17 00:00:00 2001 From: Nicholas Marriott Date: Mon, 2 Jun 2008 21:08:36 +0000 Subject: Last bits of basic configuration file. By default in ~/.tmux.conf or specified with -f. Just a list of tmux commands executed when the server is started and before and any session/window is created. --- server.c | 34 ++++++++++++++++------------------ 1 file changed, 16 insertions(+), 18 deletions(-) (limited to 'server.c') diff --git a/server.c b/server.c index 8cfc607c..ed64b424 100644 --- a/server.c +++ b/server.c @@ -1,4 +1,4 @@ -/* $Id: server.c,v 1.46 2008-06-02 18:08:17 nicm Exp $ */ +/* $Id: server.c,v 1.47 2008-06-02 21:08:36 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott @@ -55,28 +55,39 @@ void server_lost_client(struct client *); void server_lost_window(struct window *); /* Fork new server. */ -int +pid_t server_start(const char *path) { struct sockaddr_un sa; size_t size; mode_t mask; int n, fd, mode; + pid_t pid; char *cause; - switch (fork()) { + switch (pid = fork()) { case -1: fatal("fork"); case 0: break; default: - return (0); + return (pid); } #ifdef DEBUG xmalloc_clear(); #endif + ARRAY_INIT(&windows); + ARRAY_INIT(&clients); + ARRAY_INIT(&sessions); + key_bindings_init(); + + if (cfg_file != NULL && load_cfg(cfg_file, &cause) != 0) { + log_warnx("%s", cause); + exit(1); + } + logfile("server"); #ifndef NO_SETPROCTITLE setproctitle("server (%s)", path); @@ -110,17 +121,10 @@ server_start(const char *path) if (fcntl(fd, F_SETFD, FD_CLOEXEC) == -1) fatal("fcntl failed"); - /* Load configuration. */ - if (cfg_file != NULL && load_cfg(cfg_file, &cause) != 0) { - log_warnx("%s", cause); - xfree(cause); - exit(1); - } - if (daemon(1, 1) != 0) fatal("daemon failed"); log_debug("server daemonised, pid now %ld", (long) getpid()); - + n = server_main(path, fd); #ifdef DEBUG xmalloc_report(getpid(), "server"); @@ -137,12 +141,6 @@ server_main(const char *srv_path, int srv_fd) u_int i; siginit(); - - ARRAY_INIT(&windows); - ARRAY_INIT(&clients); - ARRAY_INIT(&sessions); - - key_bindings_init(); pfds = NULL; while (!sigterm) { -- cgit v1.2.3