mirror of
https://codeberg.org/dnkl/foot.git
synced 2026-02-06 04:06:06 -05:00
slave: restore signals before calling exec()
This commit is contained in:
parent
d26c67e589
commit
61dfa1365e
2 changed files with 14 additions and 1 deletions
1
main.c
1
main.c
|
|
@ -205,6 +205,7 @@ main(int argc, char *const *argv)
|
|||
if (as_server && (server = server_init(&conf, fdm, wayl)) == NULL)
|
||||
goto out;
|
||||
|
||||
/* Remember to restore signals in slave */
|
||||
const struct sigaction sa = {.sa_handler = &sig_handler};
|
||||
if (sigaction(SIGINT, &sa, NULL) < 0 || sigaction(SIGTERM, &sa, NULL) < 0) {
|
||||
LOG_ERRNO("failed to register signal handlers");
|
||||
|
|
|
|||
14
slave.c
14
slave.c
|
|
@ -5,6 +5,7 @@
|
|||
#include <unistd.h>
|
||||
#include <errno.h>
|
||||
#include <assert.h>
|
||||
#include <signal.h>
|
||||
|
||||
#include <sys/stat.h>
|
||||
#include <fcntl.h>
|
||||
|
|
@ -88,6 +89,18 @@ slave_spawn(int ptmx, int argc, char *const *argv,
|
|||
/* Child */
|
||||
close(fork_pipe[0]); /* Close read end */
|
||||
|
||||
/* Restore signals */
|
||||
const struct sigaction sa = {.sa_handler = SIG_DFL};
|
||||
if (sigaction(SIGINT, &sa, NULL) < 0 ||
|
||||
sigaction(SIGTERM, &sa, NULL) < 0 ||
|
||||
sigaction(SIGHUP, &sa, NULL) < 0)
|
||||
{
|
||||
const int _errno = errno;
|
||||
LOG_ERRNO_P("failed to restore signals", errno);
|
||||
(void)!write(fork_pipe[1], &_errno, sizeof(_errno));
|
||||
_exit(_errno);
|
||||
}
|
||||
|
||||
setenv("TERM", term_env, 1);
|
||||
|
||||
char **_shell_argv = NULL;
|
||||
|
|
@ -134,7 +147,6 @@ slave_spawn(int ptmx, int argc, char *const *argv,
|
|||
LOG_ERRNO("failed to set FD_CLOEXEC on ptmx");
|
||||
return -1;
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue