diff options
author | Nicholas Marriott <nicm@openbsd.org> | 2010-02-06 17:15:33 +0000 |
---|---|---|
committer | Nicholas Marriott <nicm@openbsd.org> | 2010-02-06 17:15:33 +0000 |
commit | 8aba77b7be489a93dc843d7ef4378bd73b5385b1 (patch) | |
tree | 060d27ad5846fc444116eb205f9b2b72c186717f /server.c | |
parent | 5e6a7c85ccdbabda01e7c05a10f7bd8dcee47e70 (diff) | |
download | rtmux-8aba77b7be489a93dc843d7ef4378bd73b5385b1.tar.gz rtmux-8aba77b7be489a93dc843d7ef4378bd73b5385b1.tar.bz2 rtmux-8aba77b7be489a93dc843d7ef4378bd73b5385b1.zip |
Instead of bailing out on the first configuration file error, carry on,
collecting all the errors, then start with the active window in more mode
displaying them.
Diffstat (limited to 'server.c')
-rw-r--r-- | server.c | 55 |
1 files changed, 29 insertions, 26 deletions
@@ -113,10 +113,11 @@ server_create_socket(void) int server_start(char *path) { - struct client *c; - int pair[2]; - char *cause, rpathbuf[MAXPATHLEN]; - struct timeval tv; + struct window_pane *wp; + int pair[2], retval; + char rpathbuf[MAXPATHLEN]; + struct timeval tv; + u_int i; /* The first client is special and gets a socketpair; create it. */ if (socketpair(AF_UNIX, SOCK_STREAM, PF_UNSPEC, pair) != 0) @@ -166,15 +167,31 @@ server_start(char *path) server_fd = server_create_socket(); server_client_create(pair[1]); - if (access(SYSTEM_CFG, R_OK) == 0) { - if (load_cfg(SYSTEM_CFG, NULL, &cause) != 0) - goto error; - } else if (errno != ENOENT) { - xasprintf(&cause, "%s: %s", strerror(errno), SYSTEM_CFG); - goto error; + retval = 0; + if (access(SYSTEM_CFG, R_OK) == 0) + load_cfg(SYSTEM_CFG, NULL, &cfg_ncauses, &cfg_causes); + else if (errno != ENOENT) { + cfg_add_cause(&cfg_ncauses, &cfg_causes, + "%s: %s", strerror(errno), SYSTEM_CFG); } - if (cfg_file != NULL && load_cfg(cfg_file, NULL, &cause) != 0) - goto error; + if (cfg_file != NULL) + load_cfg(cfg_file, NULL, &cfg_ncauses, &cfg_causes); + + /* + * If there is a session already, put the current window and pane into + * more mode. + */ + if (!ARRAY_EMPTY(&sessions) && cfg_ncauses != 0) { + wp = ARRAY_FIRST(&sessions)->curw->window->active; + window_pane_set_mode(wp, &window_more_mode); + for (i = 0; i < cfg_ncauses; i++) { + window_more_add(wp, "%s", cfg_causes[i]); + xfree(cfg_causes[i]); + } + xfree(cfg_causes); + cfg_ncauses = 0; + } + cfg_finished = 1; event_set(&server_ev_accept, server_fd, EV_READ|EV_PERSIST, server_accept_callback, NULL); @@ -188,20 +205,6 @@ server_start(char *path) server_signal_set(); server_loop(); exit(0); - -error: - /* Write the error and shutdown the server. */ - c = ARRAY_FIRST(&clients); - - server_write_error(c, cause); - server_write_client(c, MSG_EXIT, NULL, 0); - xfree(cause); - - server_shutdown = 1; - - server_signal_set(); - server_loop(); - exit(1); } /* Main server loop. */ |