aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorGravatar Arun Prakash Jana <engineerarun@gmail.com>2019-02-09 00:08:46 +0530
committerGravatar Arun Prakash Jana <engineerarun@gmail.com>2019-02-09 00:08:46 +0530
commit1253e462b83c1fa5ba928907d68159af4e9f8170 (patch)
tree9a17e3c83903997e24296c54cc08c17e156b7e93 /src
parent027af53ae0b57538166c9888b675d2ce4c979355 (diff)
downloadnnn-1253e462b83c1fa5ba928907d68159af4e9f8170.tar.gz
Use sigaction
Diffstat (limited to 'src')
-rw-r--r--src/nnn.c13
1 files changed, 9 insertions, 4 deletions
diff --git a/src/nnn.c b/src/nnn.c
index 30e82cf..6a83e8c 100644
--- a/src/nnn.c
+++ b/src/nnn.c
@@ -539,7 +539,7 @@ static uchar crc8fast(uchar const message[], size_t n)
return remainder;
}
-static void signal_handler(int signum)
+static void sigint_handler(int sig, siginfo_t *siginfo, void *context)
{
interrupted = TRUE;
}
@@ -2961,7 +2961,6 @@ begin:
populate(path, lastname);
if (interrupted) {
interrupted = FALSE;
- signal(SIGINT, &signal_handler);
cfg.apparentsz = 0;
cfg.blkorder = 0;
BLK_SHIFT = 9;
@@ -4222,8 +4221,14 @@ int main(int argc, char *argv[])
if (getenv(env_cfg[NNN_RESTRICT_0B]))
cfg.restrict0b = 1;
- /* Ignore certain signals */
- signal(SIGINT, &signal_handler);
+ /* Ignore/handle certain signals */
+ struct sigaction act = {0};
+ act.sa_sigaction = &sigint_handler;
+ act.sa_flags = SA_SIGINFO;
+ if (sigaction(SIGINT, &act, NULL) < 0) {
+ fprintf(stderr, "sigaction\n");
+ return 1;
+ }
signal(SIGQUIT, SIG_IGN);
/* Test initial path */