autofs/autofs-5.1.8-make-signal-handling-consistent.patch
2023-03-20 12:11:39 +08:00

76 lines
2.2 KiB
Diff

autofs-5.1.8 - make signal handling consistent
From: Ian Kent <raven@themaw.net>
There's a mixture of usage of sigprocmask() and pthread_sigmask(), change
to use the pthread versions of this for correctness.
The only exception to this is reset_signals() which is done in a forked
process that is single threaded so it's valid to keep them as they are.
Signed-off-by: Ian Kent <raven@themaw.net>
---
CHANGELOG | 1 +
daemon/automount.c | 8 ++++----
daemon/spawn.c | 1 -
3 files changed, 5 insertions(+), 5 deletions(-)
--- autofs-5.1.4.orig/CHANGELOG
+++ autofs-5.1.4/CHANGELOG
@@ -114,6 +114,7 @@
- dont delay expire.
- make amd mapent search function name clear.
- rename statemachine() to signal_handler().
+- make signal handling consistent.
xx/xx/2018 autofs-5.1.5
- fix flag file permission.
--- autofs-5.1.4.orig/daemon/automount.c
+++ autofs-5.1.4/daemon/automount.c
@@ -2210,7 +2210,7 @@ static void do_master_list_reset(struct
static int do_master_read_master(struct master *master, time_t *age, int wait)
{
- sigset_t signalset;
+ sigset_t signalset, savesigset;
/* Wait must be at least 1 second */
unsigned int retry_wait = 2;
unsigned int elapsed = 0;
@@ -2221,7 +2221,7 @@ static int do_master_read_master(struct
sigaddset(&signalset, SIGTERM);
sigaddset(&signalset, SIGINT);
sigaddset(&signalset, SIGHUP);
- sigprocmask(SIG_UNBLOCK, &signalset, NULL);
+ pthread_sigmask(SIG_UNBLOCK, &signalset, &savesigset);
while (1) {
struct timespec t = { retry_wait, 0 };
@@ -2247,7 +2247,7 @@ static int do_master_read_master(struct
}
}
- sigprocmask(SIG_BLOCK, &signalset, NULL);
+ pthread_sigmask(SIG_SETMASK, &savesigset, NULL);
return ret;
}
@@ -2294,7 +2294,7 @@ int main(int argc, char *argv[])
sigdelset(&block_sigs, SIGILL);
sigdelset(&block_sigs, SIGFPE);
sigdelset(&block_sigs, SIGTRAP);
- sigprocmask(SIG_BLOCK, &block_sigs, NULL);
+ pthread_sigmask(SIG_BLOCK, &block_sigs, NULL);
program = argv[0];
--- autofs-5.1.4.orig/daemon/spawn.c
+++ autofs-5.1.4/daemon/spawn.c
@@ -46,7 +46,6 @@ void dump_core(void)
sigemptyset(&segv);
sigaddset(&segv, SIGSEGV);
pthread_sigmask(SIG_UNBLOCK, &segv, NULL);
- sigprocmask(SIG_UNBLOCK, &segv, NULL);
raise(SIGSEGV);
}