mirror of
https://github.com/tmux/tmux.git
synced 2025-01-14 20:58:53 +00:00
Do not call event_del() for signals after fork(), just use sigaction()
directly instead - calling libevent functions after fork() w/o event_reinit() is a bad idea, even if in this case it was harmless.
This commit is contained in:
parent
c2822ca119
commit
e3be9b1951
@ -97,7 +97,7 @@ cmd_pipe_pane_exec(struct cmd *self, struct cmd_ctx *ctx)
|
|||||||
case 0:
|
case 0:
|
||||||
/* Child process. */
|
/* Child process. */
|
||||||
close(pipe_fd[0]);
|
close(pipe_fd[0]);
|
||||||
clear_signals();
|
clear_signals(1);
|
||||||
|
|
||||||
if (dup2(pipe_fd[1], STDIN_FILENO) == -1)
|
if (dup2(pipe_fd[1], STDIN_FILENO) == -1)
|
||||||
_exit(1);
|
_exit(1);
|
||||||
|
2
job.c
2
job.c
@ -149,7 +149,7 @@ job_run(struct job *job)
|
|||||||
case -1:
|
case -1:
|
||||||
return (-1);
|
return (-1);
|
||||||
case 0: /* child */
|
case 0: /* child */
|
||||||
clear_signals();
|
clear_signals(1);
|
||||||
|
|
||||||
environ_push(&global_environ);
|
environ_push(&global_environ);
|
||||||
|
|
||||||
|
2
server.c
2
server.c
@ -141,7 +141,7 @@ server_start(char *path)
|
|||||||
/* event_init() was called in our parent, need to reinit. */
|
/* event_init() was called in our parent, need to reinit. */
|
||||||
if (event_reinit(ev_base) != 0)
|
if (event_reinit(ev_base) != 0)
|
||||||
fatal("event_reinit failed");
|
fatal("event_reinit failed");
|
||||||
clear_signals();
|
clear_signals(0);
|
||||||
|
|
||||||
logfile("server");
|
logfile("server");
|
||||||
log_debug("server started, pid %ld", (long) getpid());
|
log_debug("server started, pid %ld", (long) getpid());
|
||||||
|
29
signal.c
29
signal.c
@ -62,7 +62,7 @@ set_signals(void(*handler)(int, short, unused void *))
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
clear_signals(void)
|
clear_signals(int after_fork)
|
||||||
{
|
{
|
||||||
struct sigaction sigact;
|
struct sigaction sigact;
|
||||||
|
|
||||||
@ -79,10 +79,25 @@ clear_signals(void)
|
|||||||
if (sigaction(SIGTSTP, &sigact, NULL) != 0)
|
if (sigaction(SIGTSTP, &sigact, NULL) != 0)
|
||||||
fatal("sigaction failed");
|
fatal("sigaction failed");
|
||||||
|
|
||||||
event_del(&ev_sighup);
|
if (after_fork) {
|
||||||
event_del(&ev_sigchld);
|
if (sigaction(SIGHUP, &sigact, NULL) != 0)
|
||||||
event_del(&ev_sigcont);
|
fatal("sigaction failed");
|
||||||
event_del(&ev_sigterm);
|
if (sigaction(SIGCHLD, &sigact, NULL) != 0)
|
||||||
event_del(&ev_sigusr1);
|
fatal("sigaction failed");
|
||||||
event_del(&ev_sigwinch);
|
if (sigaction(SIGCONT, &sigact, NULL) != 0)
|
||||||
|
fatal("sigaction failed");
|
||||||
|
if (sigaction(SIGTERM, &sigact, NULL) != 0)
|
||||||
|
fatal("sigaction failed");
|
||||||
|
if (sigaction(SIGUSR1, &sigact, NULL) != 0)
|
||||||
|
fatal("sigaction failed");
|
||||||
|
if (sigaction(SIGWINCH, &sigact, NULL) != 0)
|
||||||
|
fatal("sigaction failed");
|
||||||
|
} else {
|
||||||
|
event_del(&ev_sighup);
|
||||||
|
event_del(&ev_sigchld);
|
||||||
|
event_del(&ev_sigcont);
|
||||||
|
event_del(&ev_sigterm);
|
||||||
|
event_del(&ev_sigusr1);
|
||||||
|
event_del(&ev_sigwinch);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
4
tmux.c
4
tmux.c
@ -549,7 +549,7 @@ main(int argc, char **argv)
|
|||||||
|
|
||||||
event_dispatch();
|
event_dispatch();
|
||||||
|
|
||||||
clear_signals();
|
clear_signals(0);
|
||||||
|
|
||||||
client_main(); /* doesn't return */
|
client_main(); /* doesn't return */
|
||||||
}
|
}
|
||||||
@ -636,7 +636,7 @@ main_dispatch(const char *shellcmd)
|
|||||||
memcpy(&shelldata, imsg.data, sizeof shelldata);
|
memcpy(&shelldata, imsg.data, sizeof shelldata);
|
||||||
shelldata.shell[(sizeof shelldata.shell) - 1] = '\0';
|
shelldata.shell[(sizeof shelldata.shell) - 1] = '\0';
|
||||||
|
|
||||||
clear_signals();
|
clear_signals(0);
|
||||||
|
|
||||||
shell_exec(shelldata.shell, shellcmd);
|
shell_exec(shelldata.shell, shellcmd);
|
||||||
default:
|
default:
|
||||||
|
4
tmux.h
4
tmux.h
@ -1952,8 +1952,8 @@ void queue_window_name(struct window *);
|
|||||||
char *default_window_name(struct window *);
|
char *default_window_name(struct window *);
|
||||||
|
|
||||||
/* signal.c */
|
/* signal.c */
|
||||||
void set_signals(void(*handler)(int, short, unused void *));
|
void set_signals(void(*)(int, short, void *));
|
||||||
void clear_signals(void);
|
void clear_signals(int);
|
||||||
|
|
||||||
/* session.c */
|
/* session.c */
|
||||||
extern struct sessions sessions;
|
extern struct sessions sessions;
|
||||||
|
Loading…
Reference in New Issue
Block a user