chiark
/
gitweb
/
~ianmdlvl
/
elogind.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
5841bd8
)
core: don't do runaway fork()s if we hit a segfault from our segfault handler
author
Lennart Poettering
<lennart@poettering.net>
Thu, 27 Jun 2013 00:28:12 +0000
(
02:28
+0200)
committer
Lennart Poettering
<lennart@poettering.net>
Thu, 27 Jun 2013 02:17:33 +0000
(
04:17
+0200)
src/core/main.c
patch
|
blob
|
history
diff --git
a/src/core/main.c
b/src/core/main.c
index 470fecf15d797a29ec7cdfc865734b6351dd9bbf..c123de91cef2b52d3f95e3a4886d9753e10dc332 100644
(file)
--- a/
src/core/main.c
+++ b/
src/core/main.c
@@
-106,7
+106,10
@@
static void nop_handler(int sig) {
_noreturn_ static void crash(int sig) {
_noreturn_ static void crash(int sig) {
- if (!arg_dump_core)
+ if (getpid() != 1)
+ /* Pass this on immediately, if this is not PID 1 */
+ raise(sig);
+ else if (!arg_dump_core)
log_error("Caught <%s>, not dumping core.", signal_to_string(sig));
else {
struct sigaction sa = {
log_error("Caught <%s>, not dumping core.", signal_to_string(sig));
else {
struct sigaction sa = {
@@
-116,7
+119,7
@@
_noreturn_ static void crash(int sig) {
pid_t pid;
/* We want to wait for the core process, hence let's enable SIGCHLD */
pid_t pid;
/* We want to wait for the core process, hence let's enable SIGCHLD */
-
assert_se(sigaction(SIGCHLD, &sa, NULL) == 0
);
+
sigaction(SIGCHLD, &sa, NULL
);
pid = fork();
if (pid < 0)
pid = fork();
if (pid < 0)
@@
-128,7
+131,7
@@
_noreturn_ static void crash(int sig) {
/* Enable default signal handler for core dump */
zero(sa);
sa.sa_handler = SIG_DFL;
/* Enable default signal handler for core dump */
zero(sa);
sa.sa_handler = SIG_DFL;
-
assert_se(sigaction(sig, &sa, NULL) == 0
);
+
sigaction(sig, &sa, NULL
);
/* Don't limit the core dump size */
rl.rlim_cur = RLIM_INFINITY;
/* Don't limit the core dump size */
rl.rlim_cur = RLIM_INFINITY;
@@
-136,7
+139,7
@@
_noreturn_ static void crash(int sig) {
setrlimit(RLIMIT_CORE, &rl);
/* Just to be sure... */
setrlimit(RLIMIT_CORE, &rl);
/* Just to be sure... */
-
assert_se(chdir("/") == 0
);
+
chdir("/"
);
/* Raise the signal again */
raise(sig);
/* Raise the signal again */
raise(sig);