Page MenuHomeFreeBSD

D53761.id166465.diff
No OneTemporary

D53761.id166465.diff

diff --git a/bin/sh/miscbltin.c b/bin/sh/miscbltin.c
--- a/bin/sh/miscbltin.c
+++ b/bin/sh/miscbltin.c
@@ -162,6 +162,7 @@
int is_ifs;
int saveall = 0;
ptrdiff_t lastnonifs, lastnonifsws;
+ struct timespec tnow, tend;
struct timeval tv;
char *tvptr;
fd_set ifds;
@@ -187,7 +188,7 @@
tv.tv_sec = strtol(shoptarg, &tvptr, 0);
if (tvptr == shoptarg)
error("timeout value");
- switch(*tvptr) {
+ switch (*tvptr) {
case 0:
case 's':
break;
@@ -216,16 +217,31 @@
/*
* Wait for something to become available.
*/
+ clock_gettime(CLOCK_UPTIME, &tnow);
+ tend = tnow;
+ tend.tv_sec += tv.tv_sec;
FD_ZERO(&ifds);
FD_SET(0, &ifds);
- status = select(1, &ifds, NULL, NULL, &tv);
+ status = sig = 0;
+ while (timespeccmp(&tnow, &tend, <)) {
+ tv.tv_sec = tend.tv_sec - tnow.tv_sec;
+ tv.tv_usec = (tend.tv_nsec - tnow.tv_nsec) / 1000;
+ if (tv.tv_usec < 0) {
+ tv.tv_sec--;
+ tv.tv_usec -= 1000000;
+ }
+ status = select(1, &ifds, NULL, NULL, &tv);
+ if (status == 0 ||
+ (status < 0 && (sig = pendingsig) != 0))
+ break;
+ clock_gettime(CLOCK_UPTIME, &tnow);
+ }
/*
* If there's nothing ready, return an error.
*/
if (status <= 0) {
while (*ap != NULL)
setvar(*ap++, "", 0);
- sig = pendingsig;
return (128 + (sig != 0 ? sig : SIGALRM));
}
}

File Metadata

Mime Type
text/plain
Expires
Mon, Sep 7, 10:28 AM (1 h, 32 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
38463252
Default Alt Text
D53761.id166465.diff (1 KB)

Event Timeline