diff options
Diffstat (limited to 'src/util/scheduler.c')
-rw-r--r-- | src/util/scheduler.c | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/src/util/scheduler.c b/src/util/scheduler.c index 7254b1700..d4a11fc8a 100644 --- a/src/util/scheduler.c +++ b/src/util/scheduler.c | |||
@@ -702,6 +702,12 @@ run_ready (struct GNUNET_NETWORK_FDSet *rs, struct GNUNET_NETWORK_FDSet *ws) | |||
702 | static struct GNUNET_DISK_PipeHandle *shutdown_pipe_handle; | 702 | static struct GNUNET_DISK_PipeHandle *shutdown_pipe_handle; |
703 | 703 | ||
704 | /** | 704 | /** |
705 | * Process ID of this process at the time we installed the various | ||
706 | * signal handlers. | ||
707 | */ | ||
708 | static pid_t my_pid; | ||
709 | |||
710 | /** | ||
705 | * Signal handler called for SIGPIPE. | 711 | * Signal handler called for SIGPIPE. |
706 | */ | 712 | */ |
707 | #ifndef MINGW | 713 | #ifndef MINGW |
@@ -720,6 +726,9 @@ sighandler_shutdown () | |||
720 | static char c; | 726 | static char c; |
721 | int old_errno = errno; /* backup errno */ | 727 | int old_errno = errno; /* backup errno */ |
722 | 728 | ||
729 | if (getpid() != my_pid) | ||
730 | exit(1); /* we have fork'ed since the signal handler was created, | ||
731 | ignore the signal, see https://gnunet.org/vfork discussion */ | ||
723 | GNUNET_DISK_file_write (GNUNET_DISK_pipe_handle | 732 | GNUNET_DISK_file_write (GNUNET_DISK_pipe_handle |
724 | (shutdown_pipe_handle, GNUNET_DISK_PIPE_END_WRITE), | 733 | (shutdown_pipe_handle, GNUNET_DISK_PIPE_END_WRITE), |
725 | &c, sizeof (c)); | 734 | &c, sizeof (c)); |
@@ -799,6 +808,7 @@ GNUNET_SCHEDULER_run (GNUNET_SCHEDULER_Task task, void *task_cls) | |||
799 | pr = GNUNET_DISK_pipe_handle (shutdown_pipe_handle, | 808 | pr = GNUNET_DISK_pipe_handle (shutdown_pipe_handle, |
800 | GNUNET_DISK_PIPE_END_READ); | 809 | GNUNET_DISK_PIPE_END_READ); |
801 | GNUNET_assert (pr != NULL); | 810 | GNUNET_assert (pr != NULL); |
811 | my_pid = getpid (); | ||
802 | shc_int = GNUNET_SIGNAL_handler_install (SIGINT, &sighandler_shutdown); | 812 | shc_int = GNUNET_SIGNAL_handler_install (SIGINT, &sighandler_shutdown); |
803 | shc_term = GNUNET_SIGNAL_handler_install (SIGTERM, &sighandler_shutdown); | 813 | shc_term = GNUNET_SIGNAL_handler_install (SIGTERM, &sighandler_shutdown); |
804 | #ifndef MINGW | 814 | #ifndef MINGW |