aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorRob Landley <rob@landley.net>2016-01-28 22:10:06 -0600
committerRob Landley <rob@landley.net>2016-01-28 22:10:06 -0600
commit4a13ca98e18cea4acc8d605653d0ee8425e34f59 (patch)
tree42acd4e80890a5eab8df308c988f7bcf8dc87494 /lib
parent852740618edc876ac7416e18c2f92f78707cd708 (diff)
downloadtoybox-4a13ca98e18cea4acc8d605653d0ee8425e34f59.tar.gz
Add SIGWINCH support to top, and implement -o and -n in pgrep/pkill.
Diffstat (limited to 'lib')
-rw-r--r--lib/interestingtimes.c15
-rw-r--r--lib/net.c1
2 files changed, 11 insertions, 5 deletions
diff --git a/lib/interestingtimes.c b/lib/interestingtimes.c
index 93e2ec52..c4ea2c27 100644
--- a/lib/interestingtimes.c
+++ b/lib/interestingtimes.c
@@ -67,10 +67,14 @@ int scan_key_getsize(char *scratch, int miliwait, unsigned *xx, unsigned *yy)
{
int key;
- while (512&(key = scan_key(scratch, miliwait))) {
- if (key<0) break;
- if (xx) *xx = (key>>10)&1023;
- if (yy) *yy = (key>>20)&1023;
+ if (512&(key = scan_key(scratch, miliwait))) {
+ if (key>0) {
+ if (xx) *xx = (key>>10)&1023;
+ if (yy) *yy = (key>>20)&1023;
+ toys.signal = SIGWINCH;
+
+ return -3;
+ }
}
return key;
@@ -195,7 +199,8 @@ int scan_key(char *scratch, int miliwait)
// Read 1 byte so we don't overshoot sequence match. (We can deviate
// and fail to match, but match consumes entire buffer.)
- if (1 != read(0, scratch+1+*scratch, 1)) return -1;
+ if (toys.signal || 1 != read(0, scratch+1+*scratch, 1))
+ return toys.signal ? -3 : -1;
++*scratch;
}
diff --git a/lib/net.c b/lib/net.c
index facb0968..2e72b268 100644
--- a/lib/net.c
+++ b/lib/net.c
@@ -49,6 +49,7 @@ int xpoll(struct pollfd *fds, int nfds, int timeout)
for (;;) {
if (0>(i = poll(fds, nfds, timeout))) {
+ if (toys.signal) return i;
if (errno != EINTR && errno != ENOMEM) perror_exit("xpoll");
else if (timeout>0) timeout--;
} else return i;