aboutsummaryrefslogtreecommitdiff
path: root/miscutils
diff options
context:
space:
mode:
Diffstat (limited to 'miscutils')
-rw-r--r--miscutils/inotifyd.c11
-rw-r--r--miscutils/microcom.c20
2 files changed, 8 insertions, 23 deletions
diff --git a/miscutils/inotifyd.c b/miscutils/inotifyd.c
index 2a1a15348..3b11dc271 100644
--- a/miscutils/inotifyd.c
+++ b/miscutils/inotifyd.c
@@ -30,13 +30,6 @@
30#include "libbb.h" 30#include "libbb.h"
31#include <linux/inotify.h> 31#include <linux/inotify.h>
32 32
33static volatile smallint signalled;
34
35static void signal_handler(int signo)
36{
37 signalled = signo;
38}
39
40static const char mask_names[] ALIGN1 = 33static const char mask_names[] ALIGN1 =
41 "a" // 0x00000001 File was accessed 34 "a" // 0x00000001 File was accessed
42 "c" // 0x00000002 File was modified 35 "c" // 0x00000002 File was modified
@@ -104,14 +97,14 @@ int inotifyd_main(int argc UNUSED_PARAM, char **argv)
104 + (1 << SIGINT) 97 + (1 << SIGINT)
105 + (1 << SIGTERM) 98 + (1 << SIGTERM)
106 + (1 << SIGPIPE) 99 + (1 << SIGPIPE)
107 , signal_handler); 100 , record_signo);
108 101
109 // do watch 102 // do watch
110 103
111// pfd.fd = fd; 104// pfd.fd = fd;
112 pfd.events = POLLIN; 105 pfd.events = POLLIN;
113 106
114 while (!signalled && poll(&pfd, 1, -1) > 0) { 107 while (!bb_got_signal && poll(&pfd, 1, -1) > 0) {
115 ssize_t len; 108 ssize_t len;
116 void *buf; 109 void *buf;
117 struct inotify_event *ie; 110 struct inotify_event *ie;
diff --git a/miscutils/microcom.c b/miscutils/microcom.c
index ac3e5514f..a322197b8 100644
--- a/miscutils/microcom.c
+++ b/miscutils/microcom.c
@@ -9,14 +9,6 @@
9 */ 9 */
10#include "libbb.h" 10#include "libbb.h"
11 11
12/* All known arches use small ints for signals */
13static volatile smallint signalled;
14
15static void signal_handler(int signo)
16{
17 signalled = signo;
18}
19
20// set raw tty mode 12// set raw tty mode
21static void xget1(int fd, struct termios *t, struct termios *oldt) 13static void xget1(int fd, struct termios *t, struct termios *oldt)
22{ 14{
@@ -91,10 +83,10 @@ int microcom_main(int argc UNUSED_PARAM, char **argv)
91 + (1 << SIGINT) 83 + (1 << SIGINT)
92 + (1 << SIGTERM) 84 + (1 << SIGTERM)
93 + (1 << SIGPIPE) 85 + (1 << SIGPIPE)
94 , signal_handler); 86 , record_signo);
95 87
96 // error exit code if we fail to open the device 88 // error exit code if we fail to open the device
97 signalled = 1; 89 bb_got_signal = 1;
98 90
99 // open device 91 // open device
100 sfd = open_or_warn(argv[0], O_RDWR | O_NOCTTY | O_NONBLOCK); 92 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)
123 pfd[1].fd = STDIN_FILENO; 115 pfd[1].fd = STDIN_FILENO;
124 pfd[1].events = POLLIN; 116 pfd[1].events = POLLIN;
125 117
126 signalled = 0; 118 bb_got_signal = 0;
127 nfd = 2; 119 nfd = 2;
128 while (!signalled && safe_poll(pfd, nfd, timeout) > 0) { 120 while (!bb_got_signal && safe_poll(pfd, nfd, timeout) > 0) {
129 if (nfd > 1 && pfd[1].revents) { 121 if (nfd > 1 && pfd[1].revents) {
130 char c; 122 char c;
131 // read from stdin -> write to device 123 // read from stdin -> write to device
@@ -159,7 +151,7 @@ skip_write: ;
159 full_write(STDOUT_FILENO, iobuf, len); 151 full_write(STDOUT_FILENO, iobuf, len);
160 else { 152 else {
161 // EOF/error -> bail out 153 // EOF/error -> bail out
162 signalled = SIGHUP; 154 bb_got_signal = SIGHUP;
163 break; 155 break;
164 } 156 }
165 } 157 }
@@ -175,5 +167,5 @@ done:
175 if (device_lock_file) 167 if (device_lock_file)
176 unlink(device_lock_file); 168 unlink(device_lock_file);
177 169
178 return signalled; 170 return bb_got_signal;
179} 171}