]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
coredumpctl: let gdb handle the SIGINT signal (#4901)
authorFranck Bui <fbui@suse.com>
Sat, 17 Dec 2016 14:49:17 +0000 (15:49 +0100)
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Sat, 17 Dec 2016 14:49:17 +0000 (09:49 -0500)
Even if pressing Ctrl-c after spawning gdb with "coredumpctl gdb" is not really
useful, we should let gdb handle the signal entirely otherwise the user can be
suprised to see a different behavior when gdb is started by coredumpctl vs when
it's started directly.

Indeed in the former case, gdb exits due to coredumpctl being killed by the
signal.

So this patch makes coredumpctl ignore SIGINT as long as gdb is running.

src/coredump/coredumpctl.c

index 877bbb34fc4775a914cb5d17045f583108a58dcc..646757f9d997bb791af4f482659a8e2f1a364bb4 100644 (file)
@@ -821,6 +821,9 @@ static int run_gdb(sd_journal *j) {
         if (r < 0)
                 return r;
 
+        /* Don't interfere with gdb and its handling of SIGINT. */
+        (void) ignore_signals(SIGINT, -1);
+
         pid = fork();
         if (pid < 0) {
                 r = log_error_errno(errno, "Failed to fork(): %m");
@@ -845,6 +848,8 @@ static int run_gdb(sd_journal *j) {
         r = st.si_code == CLD_EXITED ? st.si_status : 255;
 
 finish:
+        (void) default_signals(SIGINT, -1);
+
         if (unlink_path) {
                 log_debug("Removed temporary file %s", path);
                 unlink(path);