summaryrefslogtreecommitdiffstats
path: root/usr.bin/tmux/server.c
diff options
context:
space:
mode:
authornicm <nicm@openbsd.org>2010-02-06 17:15:33 +0000
committernicm <nicm@openbsd.org>2010-02-06 17:15:33 +0000
commit9a53e128e82783ea59ef6d1323ae061f893b30e7 (patch)
tree73d3f8459a72afb2915c00727c817b42d2bf3e7c /usr.bin/tmux/server.c
parentwhen receiving the first message of an rsn group key handshake (diff)
downloadwireguard-openbsd-9a53e128e82783ea59ef6d1323ae061f893b30e7.tar.xz
wireguard-openbsd-9a53e128e82783ea59ef6d1323ae061f893b30e7.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 'usr.bin/tmux/server.c')
-rw-r--r--usr.bin/tmux/server.c57
1 files changed, 30 insertions, 27 deletions
diff --git a/usr.bin/tmux/server.c b/usr.bin/tmux/server.c
index 18ed3f6ee66..48d06644bac 100644
--- a/usr.bin/tmux/server.c
+++ b/usr.bin/tmux/server.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: server.c,v 1.81 2010/01/30 19:05:18 nicm Exp $ */
+/* $OpenBSD: server.c,v 1.82 2010/02/06 17:15:33 nicm Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
@@ -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. */