mirror of
https://github.com/tmate-io/tmate.git
synced 2025-05-06 00:54:23 +02:00
Recreate server socket on SIGUSR1, per SF feature request 2792533.
This commit is contained in:
parent
92de1ad6c8
commit
03af7c99b5
6
CHANGES
6
CHANGES
@ -1,3 +1,7 @@
|
|||||||
|
16 May 2009
|
||||||
|
|
||||||
|
* Recreate server socket on SIGUSR1, per SF feature request 2792533.
|
||||||
|
|
||||||
14 May 2009
|
14 May 2009
|
||||||
|
|
||||||
* Keys in status line (p in vi mode, M-y in emacs) to paste the first line
|
* 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
|
(including mutt, emacs). No status bar yet and no key remapping or other
|
||||||
customisation.
|
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: 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
|
LocalWords: rivo nurges lscm Erdely eol smysession mysession ek dstname RB ms
|
||||||
|
2
TODO
2
TODO
@ -87,4 +87,6 @@
|
|||||||
hardcoded 81 for left-vertical is nasty
|
hardcoded 81 for left-vertical is nasty
|
||||||
- test bug sshing from freebsd console (tom iirc?)
|
- test bug sshing from freebsd console (tom iirc?)
|
||||||
- document clear-history
|
- document clear-history
|
||||||
|
- document paste in status line
|
||||||
|
- document SIGUSR1 behaviour
|
||||||
|
|
||||||
|
42
server.c
42
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>
|
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
|
||||||
@ -43,6 +43,7 @@
|
|||||||
/* Client list. */
|
/* Client list. */
|
||||||
struct clients clients;
|
struct clients clients;
|
||||||
|
|
||||||
|
int server_create_socket(void);
|
||||||
int server_main(int);
|
int server_main(int);
|
||||||
void server_shutdown(void);
|
void server_shutdown(void);
|
||||||
void server_child_signal(void);
|
void server_child_signal(void);
|
||||||
@ -124,10 +125,7 @@ server_client_index(struct client *c)
|
|||||||
int
|
int
|
||||||
server_start(char *path)
|
server_start(char *path)
|
||||||
{
|
{
|
||||||
struct sockaddr_un sa;
|
int retcode, pair[2], srv_fd;
|
||||||
size_t size;
|
|
||||||
mode_t mask;
|
|
||||||
int n, fd, pair[2], mode;
|
|
||||||
char *cause;
|
char *cause;
|
||||||
#ifdef HAVE_SETPROCTITLE
|
#ifdef HAVE_SETPROCTITLE
|
||||||
char rpathbuf[MAXPATHLEN];
|
char rpathbuf[MAXPATHLEN];
|
||||||
@ -187,6 +185,25 @@ server_start(char *path)
|
|||||||
setproctitle("server (%s)", rpathbuf);
|
setproctitle("server (%s)", rpathbuf);
|
||||||
#endif
|
#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);
|
memset(&sa, 0, sizeof sa);
|
||||||
sa.sun_family = AF_UNIX;
|
sa.sun_family = AF_UNIX;
|
||||||
size = strlcpy(sa.sun_path, socket_path, sizeof sa.sun_path);
|
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)
|
if (fcntl(fd, F_SETFD, FD_CLOEXEC) == -1)
|
||||||
fatal("fcntl failed");
|
fatal("fcntl failed");
|
||||||
|
|
||||||
server_create_client(pair[1]);
|
return (fd);
|
||||||
|
|
||||||
n = server_main(fd);
|
|
||||||
#ifdef DEBUG
|
|
||||||
xmalloc_report(getpid(), "server");
|
|
||||||
#endif
|
|
||||||
exit(n);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Main server loop. */
|
/* Main server loop. */
|
||||||
@ -249,6 +260,13 @@ server_main(int srv_fd)
|
|||||||
sigchld = 0;
|
sigchld = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Recreate socket on SIGUSR1. */
|
||||||
|
if (sigusr1) {
|
||||||
|
close(srv_fd);
|
||||||
|
srv_fd = server_create_socket();
|
||||||
|
sigusr1 = 0;
|
||||||
|
}
|
||||||
|
|
||||||
/* Initialise pollfd array. */
|
/* Initialise pollfd array. */
|
||||||
nfds = 1;
|
nfds = 1;
|
||||||
for (i = 0; i < ARRAY_LENGTH(&windows); i++) {
|
for (i = 0; i < ARRAY_LENGTH(&windows); i++) {
|
||||||
|
18
tmux.c
18
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>
|
* 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 sigterm;
|
||||||
volatile sig_atomic_t sigcont;
|
volatile sig_atomic_t sigcont;
|
||||||
volatile sig_atomic_t sigchld;
|
volatile sig_atomic_t sigchld;
|
||||||
|
volatile sig_atomic_t sigusr1;
|
||||||
|
volatile sig_atomic_t sigusr2;
|
||||||
|
|
||||||
char *cfg_file;
|
char *cfg_file;
|
||||||
struct options global_options;
|
struct options global_options;
|
||||||
@ -110,6 +112,12 @@ sighandler(int sig)
|
|||||||
case SIGCONT:
|
case SIGCONT:
|
||||||
sigcont = 1;
|
sigcont = 1;
|
||||||
break;
|
break;
|
||||||
|
case SIGUSR1:
|
||||||
|
sigusr1 = 1;
|
||||||
|
break;
|
||||||
|
case SIGUSR2:
|
||||||
|
sigusr2 = 1;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
errno = saved_errno;
|
errno = saved_errno;
|
||||||
}
|
}
|
||||||
@ -126,10 +134,6 @@ siginit(void)
|
|||||||
act.sa_handler = SIG_IGN;
|
act.sa_handler = SIG_IGN;
|
||||||
if (sigaction(SIGPIPE, &act, NULL) != 0)
|
if (sigaction(SIGPIPE, &act, NULL) != 0)
|
||||||
fatal("sigaction failed");
|
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)
|
if (sigaction(SIGINT, &act, NULL) != 0)
|
||||||
fatal("sigaction failed");
|
fatal("sigaction failed");
|
||||||
if (sigaction(SIGTSTP, &act, NULL) != 0)
|
if (sigaction(SIGTSTP, &act, NULL) != 0)
|
||||||
@ -144,6 +148,10 @@ siginit(void)
|
|||||||
fatal("sigaction failed");
|
fatal("sigaction failed");
|
||||||
if (sigaction(SIGCHLD, &act, NULL) != 0)
|
if (sigaction(SIGCHLD, &act, NULL) != 0)
|
||||||
fatal("sigaction failed");
|
fatal("sigaction failed");
|
||||||
|
if (sigaction(SIGUSR1, &act, NULL) != 0)
|
||||||
|
fatal("sigaction failed");
|
||||||
|
if (sigaction(SIGUSR2, &act, NULL) != 0)
|
||||||
|
fatal("sigaction failed");
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
4
tmux.h
4
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>
|
* 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 sigterm;
|
||||||
extern volatile sig_atomic_t sigcont;
|
extern volatile sig_atomic_t sigcont;
|
||||||
extern volatile sig_atomic_t sigchld;
|
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_options;
|
||||||
extern struct options global_window_options;
|
extern struct options global_window_options;
|
||||||
extern char *cfg_file;
|
extern char *cfg_file;
|
||||||
|
Loading…
Reference in New Issue
Block a user