mirror of
https://codeberg.org/dnkl/foot.git
synced 2026-02-04 04:06:06 -05:00
spawn/slave: restore signal mask after fork
slave: no need to restore signal handlers; they are automatically restored as long as they are not SIG_IGN (which they never are in foot). spawn(): restore signal mask after fork. This fixes an issue where a terminal spawned with ctrl+shift+n did not terminate when its shell exited. Closes #366
This commit is contained in:
parent
34f89fbe72
commit
dd5c31657e
4 changed files with 15 additions and 8 deletions
|
|
@ -81,6 +81,8 @@
|
|||
`shift` to be pressed while used in a mouse grabbing
|
||||
application. This meant the mouse event was never seen by the
|
||||
application.
|
||||
* Terminals spawned with `ctrl`+`shift`+`n` not terminating when
|
||||
exiting shell (https://codeberg.org/dnkl/foot/issues/366).
|
||||
|
||||
|
||||
### Security
|
||||
|
|
|
|||
1
fdm.c
1
fdm.c
|
|
@ -27,7 +27,6 @@ struct fd_handler {
|
|||
};
|
||||
|
||||
struct sig_handler {
|
||||
int signo;
|
||||
fdm_signal_handler_t callback;
|
||||
void *callback_data;
|
||||
};
|
||||
|
|
|
|||
9
slave.c
9
slave.c
|
|
@ -274,15 +274,10 @@ slave_spawn(int ptmx, int argc, const char *cwd, char *const *argv,
|
|||
_exit(_errno);
|
||||
}
|
||||
|
||||
/* Restore signals */
|
||||
/* Restore signal mask */
|
||||
sigset_t mask;
|
||||
sigemptyset(&mask);
|
||||
const struct sigaction sa = {.sa_handler = SIG_DFL};
|
||||
if (sigaction(SIGINT, &sa, NULL) < 0 ||
|
||||
sigaction(SIGTERM, &sa, NULL) < 0 ||
|
||||
sigaction(SIGHUP, &sa, NULL) < 0 ||
|
||||
sigprocmask(SIG_SETMASK, &mask, NULL) < 0)
|
||||
{
|
||||
if (sigprocmask(SIG_SETMASK, &mask, NULL) < 0) {
|
||||
const int _errno = errno;
|
||||
LOG_ERRNO_P(errno, "failed to restore signals");
|
||||
(void)!write(fork_pipe[1], &_errno, sizeof(_errno));
|
||||
|
|
|
|||
11
spawn.c
11
spawn.c
|
|
@ -3,6 +3,7 @@
|
|||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
#include <errno.h>
|
||||
#include <signal.h>
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
|
|
@ -34,6 +35,16 @@ spawn(struct reaper *reaper, const char *cwd, char *const argv[],
|
|||
/* Child */
|
||||
close(pipe_fds[0]);
|
||||
|
||||
/* Clear signal mask */
|
||||
sigset_t mask;
|
||||
sigemptyset(&mask);
|
||||
if (sigprocmask(SIG_SETMASK, &mask, NULL) < 0) {
|
||||
const int _errno = errno;
|
||||
LOG_ERRNO_P(errno, "failed to restore signals");
|
||||
(void)!write(pipe_fds[1], &_errno, sizeof(_errno));
|
||||
_exit(_errno);
|
||||
}
|
||||
|
||||
if ((stdin_fd >= 0 && (dup2(stdin_fd, STDIN_FILENO) < 0 || close(stdin_fd) < 0)) ||
|
||||
(stdout_fd >= 0 && (dup2(stdout_fd, STDOUT_FILENO) < 0 || close(stdout_fd) < 0)) ||
|
||||
(stderr_fd >= 0 && (dup2(stderr_fd, STDERR_FILENO) < 0 || close(stderr_fd) < 0)) ||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue