Andrew Geissler | 748a483 | 2020-07-24 16:24:21 -0500 | [diff] [blame^] | 1 | From b9040acdba1245f8cdf5e94384830e3d04fde98a Mon Sep 17 00:00:00 2001 |
| 2 | From: Khem Raj <raj.khem@gmail.com> |
| 3 | Date: Wed, 22 Jul 2020 21:32:14 -0700 |
| 4 | Subject: [PATCH] Replace sigignore with signal API |
| 5 | |
| 6 | sigignore has been deprecated in glibc 2.32+ [1] and eventually it will be |
| 7 | removed, therefore substitute it |
| 8 | |
| 9 | [1] https://sourceware.org/git/?p=glibc.git;a=commit;h=02802fafcf6e11ea3f998f685035ffe568dfddeb |
| 10 | |
| 11 | Upstream-Status: Submitted [https://github.com/memcached/memcached/pull/702] |
| 12 | |
| 13 | Signed-off-by: Khem Raj <raj.khem@gmail.com> |
| 14 | --- |
| 15 | configure.ac | 1 - |
| 16 | memcached.c | 16 ++-------------- |
| 17 | 2 files changed, 2 insertions(+), 15 deletions(-) |
| 18 | |
| 19 | diff --git a/configure.ac b/configure.ac |
| 20 | index ffc98b2..4567b30 100644 |
| 21 | --- a/configure.ac |
| 22 | +++ b/configure.ac |
| 23 | @@ -630,7 +630,6 @@ AC_CHECK_FUNCS(mlockall) |
| 24 | AC_CHECK_FUNCS(getpagesizes) |
| 25 | AC_CHECK_FUNCS(sysconf) |
| 26 | AC_CHECK_FUNCS(memcntl) |
| 27 | -AC_CHECK_FUNCS(sigignore) |
| 28 | AC_CHECK_FUNCS(clock_gettime) |
| 29 | AC_CHECK_FUNCS(preadv) |
| 30 | AC_CHECK_FUNCS(pread) |
| 31 | diff --git a/memcached.c b/memcached.c |
| 32 | index 9cb778d..91ced9e 100644 |
| 33 | --- a/memcached.c |
| 34 | +++ b/memcached.c |
| 35 | @@ -8292,18 +8292,6 @@ static void sig_usrhandler(const int sig) { |
| 36 | stop_main_loop = GRACE_STOP; |
| 37 | } |
| 38 | |
| 39 | -#ifndef HAVE_SIGIGNORE |
| 40 | -static int sigignore(int sig) { |
| 41 | - struct sigaction sa = { .sa_handler = SIG_IGN, .sa_flags = 0 }; |
| 42 | - |
| 43 | - if (sigemptyset(&sa.sa_mask) == -1 || sigaction(sig, &sa, 0) == -1) { |
| 44 | - return -1; |
| 45 | - } |
| 46 | - return 0; |
| 47 | -} |
| 48 | -#endif |
| 49 | - |
| 50 | - |
| 51 | /* |
| 52 | * On systems that supports multiple page sizes we may reduce the |
| 53 | * number of TLB-misses by using the biggest available page size |
| 54 | @@ -9996,7 +9984,7 @@ int main (int argc, char **argv) { |
| 55 | /* daemonize if requested */ |
| 56 | /* if we want to ensure our ability to dump core, don't chdir to / */ |
| 57 | if (do_daemonize) { |
| 58 | - if (sigignore(SIGHUP) == -1) { |
| 59 | + if (signal(SIGHUP, SIG_IGN) == SIG_ERR) { |
| 60 | perror("Failed to ignore SIGHUP"); |
| 61 | } |
| 62 | if (daemonize(maxcore, settings.verbose) == -1) { |
| 63 | @@ -10146,7 +10134,7 @@ int main (int argc, char **argv) { |
| 64 | * ignore SIGPIPE signals; we can use errno == EPIPE if we |
| 65 | * need that information |
| 66 | */ |
| 67 | - if (sigignore(SIGPIPE) == -1) { |
| 68 | + if (signal(SIGPIPE, SIG_IGN) == SIG_ERR) { |
| 69 | perror("failed to ignore SIGPIPE; sigaction"); |
| 70 | exit(EX_OSERR); |
| 71 | } |
| 72 | -- |
| 73 | 2.27.0 |
| 74 | |