Move -s and -c down a level so handling them is the responsibility of the command (with some helper functions), rather than the top-level. This changes the action command syntax so that -s and -c must be after the command rather than before.

This commit is contained in:
Nicholas Marriott
2008-06-02 18:08:17 +00:00
parent 11ee55e755
commit c7243b73cb
42 changed files with 1086 additions and 437 deletions

View File

@@ -1,4 +1,4 @@
/* $Id: server.c,v 1.45 2008-05-31 20:04:15 nicm Exp $ */
/* $Id: server.c,v 1.46 2008-06-02 18:08:17 nicm Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
@@ -62,6 +62,7 @@ server_start(const char *path)
size_t size;
mode_t mask;
int n, fd, mode;
char *cause;
switch (fork()) {
case -1:
@@ -109,6 +110,13 @@ 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());
@@ -135,7 +143,7 @@ server_main(const char *srv_path, int srv_fd)
ARRAY_INIT(&sessions);
key_bindings_init();
pfds = NULL;
while (!sigterm) {
/* Initialise pollfd array. */