*/
#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)
{
+ (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);
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
full_write(STDOUT_FILENO, iobuf, len);
else {
// EOF/error -> bail out
- signalled = SIGHUP;
+ bb_got_signal = SIGHUP;
break;
}
}
if (device_lock_file)
unlink(device_lock_file);
- return signalled;
+ return bb_got_signal;
}