From: nicm Date: Tue, 21 Apr 2015 22:32:40 +0000 (+0000) Subject: Do not die on USR1 if any of the socket parent directories are X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=d53cf33d80504df57db16413bb1931a033d8066f;p=openbsd Do not die on USR1 if any of the socket parent directories are missing. Reported by Robin Powell. --- diff --git a/usr.bin/tmux/server.c b/usr.bin/tmux/server.c index da8f82ed49d..b7f1537c643 100644 --- a/usr.bin/tmux/server.c +++ b/usr.bin/tmux/server.c @@ -1,4 +1,4 @@ -/* $OpenBSD: server.c,v 1.118 2014/12/09 19:23:35 nicm Exp $ */ +/* $OpenBSD: server.c,v 1.119 2015/04/21 22:32:40 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott @@ -79,24 +79,22 @@ server_create_socket(void) size = strlcpy(sa.sun_path, socket_path, sizeof sa.sun_path); if (size >= sizeof sa.sun_path) { errno = ENAMETOOLONG; - fatal("socket failed"); + return (-1); } unlink(sa.sun_path); if ((fd = socket(AF_UNIX, SOCK_STREAM, 0)) == -1) - fatal("socket failed"); + return (-1); mask = umask(S_IXUSR|S_IXGRP|S_IRWXO); if (bind(fd, (struct sockaddr *) &sa, SUN_LEN(&sa)) == -1) - fatal("bind failed"); + return (-1); umask(mask); if (listen(fd, 16) == -1) - fatal("listen failed"); + return (-1); setblocking(fd, 0); - server_update_socket(); - return (fd); } @@ -155,6 +153,9 @@ server_start(int lockfd, char *lockfile) setproctitle("server (%s)", socket_path); server_fd = server_create_socket(); + if (server_fd == -1) + fatal("couldn't create socket"); + server_update_socket(); server_client_create(pair[1]); unlink(lockfile); @@ -387,6 +388,7 @@ server_add_accept(int timeout) void server_signal_callback(int sig, unused short events, unused void *data) { + int fd; switch (sig) { case SIGTERM: server_shutdown = 1; @@ -397,8 +399,12 @@ server_signal_callback(int sig, unused short events, unused void *data) break; case SIGUSR1: event_del(&server_ev_accept); - close(server_fd); - server_fd = server_create_socket(); + fd = server_create_socket(); + if (fd != -1) { + close(server_fd); + server_fd = fd; + server_update_socket(); + } server_add_accept(0); break; } diff --git a/usr.bin/tmux/tmux.1 b/usr.bin/tmux/tmux.1 index 108479eccb1..41fcfcbef71 100644 --- a/usr.bin/tmux/tmux.1 +++ b/usr.bin/tmux/tmux.1 @@ -1,4 +1,4 @@ -.\" $OpenBSD: tmux.1,v 1.421 2015/04/20 15:34:56 nicm Exp $ +.\" $OpenBSD: tmux.1,v 1.422 2015/04/21 22:32:40 nicm Exp $ .\" .\" Copyright (c) 2007 Nicholas Marriott .\" @@ -14,7 +14,7 @@ .\" IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING .\" OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. .\" -.Dd $Mdocdate: April 20 2015 $ +.Dd $Mdocdate: April 21 2015 $ .Dt TMUX 1 .Os .Sh NAME @@ -163,7 +163,8 @@ If the socket is accidentally removed, the .Dv SIGUSR1 signal may be sent to the .Nm -server process to recreate it. +server process to recreate it (note that this will fail if any parent +directories are missing). .It Fl l Behave as a login shell. This flag currently has no effect and is for compatibility with other shells @@ -2004,7 +2005,8 @@ is bound in .Ar mode-table : the binding for command mode with .Fl c -or for normal mode without. See the +or for normal mode without. +See the .Sx WINDOWS AND PANES section and the .Ic list-keys