chiark
/
gitweb
/
~ianmdlvl
/
elogind.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
util: reset signals when we fork off agents
[elogind.git]
/
src
/
shared
/
util.c
diff --git
a/src/shared/util.c
b/src/shared/util.c
index 4af2d3cebad19a261a3134a162b20f6520f419ae..98c07163da28e8e871ef976392300c67f8d94bbe 100644
(file)
--- a/
src/shared/util.c
+++ b/
src/shared/util.c
@@
-959,6
+959,18
@@
int reset_all_signal_handlers(void) {
return r;
}
return r;
}
+int reset_signal_mask(void) {
+ sigset_t ss;
+
+ if (sigemptyset(&ss) < 0)
+ return -errno;
+
+ if (sigprocmask(SIG_SETMASK, &ss, NULL) < 0)
+ return -errno;
+
+ return 0;
+}
+
char *strstrip(char *s) {
char *e;
char *strstrip(char *s) {
char *e;
@@
-5131,6
+5143,12
@@
int fork_agent(pid_t *pid, const int except[], unsigned n_except, const char *pa
/* Don't leak fds to the agent */
close_all_fds(except, n_except);
/* Don't leak fds to the agent */
close_all_fds(except, n_except);
+ /* Make sure we actually can kill the agent, if we need to, in
+ * case somebody invoked us from a shell script that trapped
+ * SIGTERM or so... */
+ reset_all_signal_handlers();
+ reset_signal_mask();
+
stdout_is_tty = isatty(STDOUT_FILENO);
stderr_is_tty = isatty(STDERR_FILENO);
stdout_is_tty = isatty(STDOUT_FILENO);
stderr_is_tty = isatty(STDERR_FILENO);