diff options
author | Gleicon Moraes <gleicon@gmail.com> | 2018-07-26 22:48:37 -0300 |
---|---|---|
committer | dormando <dormando@rydia.net> | 2018-08-08 18:02:18 -0700 |
commit | 4d628b41e84e8996074bca9a3347b1a5afca0cfc (patch) | |
tree | 6c38bc752ce8af6f36637b847984d0735ba32e9c /timedrun.c | |
parent | 93dfe276c79803f1f6950ea183c260ce73ddb304 (diff) | |
download | memcached-4d628b41e84e8996074bca9a3347b1a5afca0cfc.tar.gz |
Followed directions of issue 386 regarding posix signals
Diffstat (limited to 'timedrun.c')
-rw-r--r-- | timedrun.c | 12 |
1 files changed, 6 insertions, 6 deletions
@@ -7,11 +7,11 @@ #include <assert.h> -static int caught = 0; +volatile sig_atomic_t caught_sig = 0; -static void caught_signal(int which) +static void signal_handler(int which) { - caught = which; + caught_sig = which; } static int wait_for_process(pid_t pid) @@ -21,7 +21,7 @@ static int wait_for_process(pid_t pid) int i = 0; struct sigaction sig_handler; - sig_handler.sa_handler = caught_signal; + sig_handler.sa_handler = signal_handler; sig_handler.sa_flags = 0; sigaction(SIGALRM, &sig_handler, NULL); @@ -44,8 +44,8 @@ static int wait_for_process(pid_t pid) switch (i) { case 0: /* On the first iteration, pass the signal through */ - sig = caught > 0 ? caught : SIGTERM; - if (caught == SIGALRM) { + sig = caught_sig > 0 ? caught_sig : SIGTERM; + if (caught_sig == SIGALRM) { fprintf(stderr, "Timeout.. killing the process\n"); } break; |