diff options
Diffstat (limited to 'miscutils')
-rw-r--r-- | miscutils/inotifyd.c | 11 | ||||
-rw-r--r-- | miscutils/microcom.c | 20 |
2 files changed, 8 insertions, 23 deletions
diff --git a/miscutils/inotifyd.c b/miscutils/inotifyd.c index 2a1a153..3b11dc2 100644 --- a/miscutils/inotifyd.c +++ b/miscutils/inotifyd.c @@ -30,13 +30,6 @@ #include "libbb.h" #include <linux/inotify.h> -static volatile smallint signalled; - -static void signal_handler(int signo) -{ - signalled = signo; -} - static const char mask_names[] ALIGN1 = "a" // 0x00000001 File was accessed "c" // 0x00000002 File was modified @@ -104,14 +97,14 @@ int inotifyd_main(int argc UNUSED_PARAM, char **argv) + (1 << SIGINT) + (1 << SIGTERM) + (1 << SIGPIPE) - , signal_handler); + , record_signo); // do watch // pfd.fd = fd; pfd.events = POLLIN; - while (!signalled && poll(&pfd, 1, -1) > 0) { + while (!bb_got_signal && poll(&pfd, 1, -1) > 0) { ssize_t len; void *buf; struct inotify_event *ie; diff --git a/miscutils/microcom.c b/miscutils/microcom.c index ac3e551..a322197 100644 --- a/miscutils/microcom.c +++ b/miscutils/microcom.c @@ -9,14 +9,6 @@ */ #include "libbb.h" -/* All known arches use small ints for signals */ -static volatile smallint signalled; - -static void signal_handler(int signo) -{ - signalled = signo; -} - // set raw tty mode static void xget1(int fd, struct termios *t, struct termios *oldt) { @@ -91,10 +83,10 @@ int microcom_main(int argc UNUSED_PARAM, char **argv) + (1 << SIGINT) + (1 << SIGTERM) + (1 << SIGPIPE) - , signal_handler); + , record_signo); // error exit code if we fail to open the device - signalled = 1; + bb_got_signal = 1; // open device sfd = open_or_warn(argv[0], O_RDWR | O_NOCTTY | O_NONBLOCK); @@ -123,9 +115,9 @@ int microcom_main(int argc UNUSED_PARAM, char **argv) pfd[1].fd = STDIN_FILENO; pfd[1].events = POLLIN; - signalled = 0; + bb_got_signal = 0; nfd = 2; - while (!signalled && safe_poll(pfd, nfd, timeout) > 0) { + while (!bb_got_signal && safe_poll(pfd, nfd, timeout) > 0) { if (nfd > 1 && pfd[1].revents) { char c; // read from stdin -> write to device @@ -159,7 +151,7 @@ skip_write: ; full_write(STDOUT_FILENO, iobuf, len); else { // EOF/error -> bail out - signalled = SIGHUP; + bb_got_signal = SIGHUP; break; } } @@ -175,5 +167,5 @@ done: if (device_lock_file) unlink(device_lock_file); - return signalled; + return bb_got_signal; } |