aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNicholas Marriott <nicholas.marriott@gmail.com>2009-05-16 10:02:51 +0000
committerNicholas Marriott <nicholas.marriott@gmail.com>2009-05-16 10:02:51 +0000
commit03af7c99b58d65cd9ec0a95e02658c152e18f41e (patch)
tree9027df02bbdf4d2c6556acaef4479b15dbd60c15
parent92de1ad6c833ec8253e07be2a10689b7f5f2c9a6 (diff)
downloadrtmux-03af7c99b58d65cd9ec0a95e02658c152e18f41e.tar.gz
rtmux-03af7c99b58d65cd9ec0a95e02658c152e18f41e.tar.bz2
rtmux-03af7c99b58d65cd9ec0a95e02658c152e18f41e.zip
Recreate server socket on SIGUSR1, per SF feature request 2792533.
-rw-r--r--CHANGES6
-rw-r--r--TODO2
-rw-r--r--server.c46
-rw-r--r--tmux.c18
-rw-r--r--tmux.h4
5 files changed, 55 insertions, 21 deletions
diff --git a/CHANGES b/CHANGES
index 70e9f04e..0a2d6e21 100644
--- a/CHANGES
+++ b/CHANGES
@@ -1,3 +1,7 @@
+16 May 2009
+
+* Recreate server socket on SIGUSR1, per SF feature request 2792533.
+
14 May 2009
* Keys in status line (p in vi mode, M-y in emacs) to paste the first line
@@ -1257,7 +1261,7 @@
(including mutt, emacs). No status bar yet and no key remapping or other
customisation.
-$Id: CHANGES,v 1.288 2009-05-14 19:36:56 nicm Exp $
+$Id: CHANGES,v 1.289 2009-05-16 10:02:51 nicm Exp $
LocalWords: showw utf UTF fulvio ciriaco joshe OSC APC gettime abc DEF OA clr
LocalWords: rivo nurges lscm Erdely eol smysession mysession ek dstname RB ms
diff --git a/TODO b/TODO
index 7e302335..b5044bd2 100644
--- a/TODO
+++ b/TODO
@@ -87,4 +87,6 @@
hardcoded 81 for left-vertical is nasty
- test bug sshing from freebsd console (tom iirc?)
- document clear-history
+- document paste in status line
+- document SIGUSR1 behaviour
diff --git a/server.c b/server.c
index 7d87371c..5eea4a14 100644
--- a/server.c
+++ b/server.c
@@ -1,4 +1,4 @@
-/* $Id: server.c,v 1.142 2009-05-14 07:58:38 nicm Exp $ */
+/* $Id: server.c,v 1.143 2009-05-16 10:02:51 nicm Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
@@ -43,6 +43,7 @@
/* Client list. */
struct clients clients;
+int server_create_socket(void);
int server_main(int);
void server_shutdown(void);
void server_child_signal(void);
@@ -124,13 +125,10 @@ server_client_index(struct client *c)
int
server_start(char *path)
{
- struct sockaddr_un sa;
- size_t size;
- mode_t mask;
- int n, fd, pair[2], mode;
- char *cause;
+ int retcode, pair[2], srv_fd;
+ char *cause;
#ifdef HAVE_SETPROCTITLE
- char rpathbuf[MAXPATHLEN];
+ char rpathbuf[MAXPATHLEN];
#endif
/* The first client is special and gets a socketpair; create it. */
@@ -187,6 +185,25 @@ server_start(char *path)
setproctitle("server (%s)", rpathbuf);
#endif
+ srv_fd = server_create_socket();
+ server_create_client(pair[1]);
+
+ retcode = server_main(srv_fd);
+#ifdef DEBUG
+ xmalloc_report(getpid(), "server");
+#endif
+ exit(retcode);
+}
+
+/* Create server socket. */
+int
+server_create_socket(void)
+{
+ struct sockaddr_un sa;
+ size_t size;
+ mode_t mask;
+ int fd, mode;
+
memset(&sa, 0, sizeof sa);
sa.sun_family = AF_UNIX;
size = strlcpy(sa.sun_path, socket_path, sizeof sa.sun_path);
@@ -214,13 +231,7 @@ server_start(char *path)
if (fcntl(fd, F_SETFD, FD_CLOEXEC) == -1)
fatal("fcntl failed");
- server_create_client(pair[1]);
-
- n = server_main(fd);
-#ifdef DEBUG
- xmalloc_report(getpid(), "server");
-#endif
- exit(n);
+ return (fd);
}
/* Main server loop. */
@@ -249,6 +260,13 @@ server_main(int srv_fd)
sigchld = 0;
}
+ /* Recreate socket on SIGUSR1. */
+ if (sigusr1) {
+ close(srv_fd);
+ srv_fd = server_create_socket();
+ sigusr1 = 0;
+ }
+
/* Initialise pollfd array. */
nfds = 1;
for (i = 0; i < ARRAY_LENGTH(&windows); i++) {
diff --git a/tmux.c b/tmux.c
index ca9d1caa..e93b96b5 100644
--- a/tmux.c
+++ b/tmux.c
@@ -1,4 +1,4 @@
-/* $Id: tmux.c,v 1.116 2009-05-13 23:27:00 nicm Exp $ */
+/* $Id: tmux.c,v 1.117 2009-05-16 10:02:51 nicm Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
@@ -47,6 +47,8 @@ volatile sig_atomic_t sigwinch;
volatile sig_atomic_t sigterm;
volatile sig_atomic_t sigcont;
volatile sig_atomic_t sigchld;
+volatile sig_atomic_t sigusr1;
+volatile sig_atomic_t sigusr2;
char *cfg_file;
struct options global_options;
@@ -110,6 +112,12 @@ sighandler(int sig)
case SIGCONT:
sigcont = 1;
break;
+ case SIGUSR1:
+ sigusr1 = 1;
+ break;
+ case SIGUSR2:
+ sigusr2 = 1;
+ break;
}
errno = saved_errno;
}
@@ -126,10 +134,6 @@ siginit(void)
act.sa_handler = SIG_IGN;
if (sigaction(SIGPIPE, &act, NULL) != 0)
fatal("sigaction failed");
- if (sigaction(SIGUSR1, &act, NULL) != 0)
- fatal("sigaction failed");
- if (sigaction(SIGUSR2, &act, NULL) != 0)
- fatal("sigaction failed");
if (sigaction(SIGINT, &act, NULL) != 0)
fatal("sigaction failed");
if (sigaction(SIGTSTP, &act, NULL) != 0)
@@ -144,6 +148,10 @@ siginit(void)
fatal("sigaction failed");
if (sigaction(SIGCHLD, &act, NULL) != 0)
fatal("sigaction failed");
+ if (sigaction(SIGUSR1, &act, NULL) != 0)
+ fatal("sigaction failed");
+ if (sigaction(SIGUSR2, &act, NULL) != 0)
+ fatal("sigaction failed");
}
void
diff --git a/tmux.h b/tmux.h
index 2a7c543b..bab5503b 100644
--- a/tmux.h
+++ b/tmux.h
@@ -1,4 +1,4 @@
-/* $Id: tmux.h,v 1.316 2009-05-14 19:36:56 nicm Exp $ */
+/* $Id: tmux.h,v 1.317 2009-05-16 10:02:51 nicm Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
@@ -1060,6 +1060,8 @@ extern volatile sig_atomic_t sigwinch;
extern volatile sig_atomic_t sigterm;
extern volatile sig_atomic_t sigcont;
extern volatile sig_atomic_t sigchld;
+extern volatile sig_atomic_t sigusr1;
+extern volatile sig_atomic_t sigusr2;
extern struct options global_options;
extern struct options global_window_options;
extern char *cfg_file;