aboutsummaryrefslogtreecommitdiff
path: root/miscutils/microcom.c
diff options
context:
space:
mode:
authorDenis Vlasenko <vda.linux@googlemail.com>2008-09-11 19:51:11 +0000
committerDenis Vlasenko <vda.linux@googlemail.com>2008-09-11 19:51:11 +0000
commit08ea11ab0749a7977e6d47cd0fa7b3c9cc10af32 (patch)
tree84049bf86fbcbe95ad0443816efd07f8c02c1288 /miscutils/microcom.c
parent9725daa03a7806b1c9c5a3c511dfe2ff9f97dd26 (diff)
downloadbusybox-08ea11ab0749a7977e6d47cd0fa7b3c9cc10af32.tar.gz
runsvd: shrink by Vladimir
*: use unified trivial signal handler function old new delta record_signo - 10 +10 process_stdin 433 443 +10 bbunpack 383 391 +8 wc_main 598 605 +7 conescape 293 296 +3 nmeter_main 670 672 +2 fallbackSort 1717 1719 +2 bb_got_signal - 1 +1 microcom_main 713 712 -1 signalled 2 - -2 pack_gzip 1661 1659 -2 evalvar 1376 1374 -2 compare_keys 737 735 -2 parse_command 1460 1456 -4 expand 1748 1744 -4 s_term 37 29 -8 s_hangup 8 - -8 fgotsig 10 - -10 find_pair 187 169 -18 signal_handler 190 170 -20 runsvdir_main 1701 1583 -118 ------------------------------------------------------------------------------ (add/remove: 2/3 grow/shrink: 6/10 up/down: 43/-199) Total: -156 bytes
Diffstat (limited to 'miscutils/microcom.c')
-rw-r--r--miscutils/microcom.c20
1 files changed, 6 insertions, 14 deletions
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 @@
*/
#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;
}