Skip to content

Commit b1f2431

Browse files
hostileforkOldes
authored andcommitted
ATRONIX: by Hostile Fork - Quietly tolerate EINTR in POSIX %dev-event.c
Doing Ctrl-C during a timer wait would print out the string ERROR!!!! and then cancel. Since there was no particular handling of the error besides printing the message, this suppresses the message in the EINTR case (though still returns an error code).
1 parent 0395c77 commit b1f2431

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

src/os/posix/dev-event.c

+11-2
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@
4141
#include <string.h>
4242
#include <unistd.h>
4343
#include <sys/time.h>
44+
#include <errno.h>
4445

4546
#include "reb-host.h"
4647
#include "host-lib.h"
@@ -103,8 +104,16 @@ void Done_Device(int handle, int error);
103104

104105
result = select(0, 0, 0, 0, &tv);
105106
if (result < 0) {
106-
// !!! set error code
107-
printf("ERROR!!!!\n");
107+
//
108+
// !!! In R3-Alpha this had a TBD that said "set error code" and had a
109+
// printf that said "ERROR!!!!". However this can happen when a
110+
// Ctrl-C interrupts a timer on a WAIT. As a patch this is tolerant
111+
// of EINTR, but still returns the error code. :-/
112+
//
113+
if (errno == EINTR)
114+
return DR_ERROR;
115+
116+
printf("select() returned -1 in dev-event.c (I/O error!)\n");
108117
return DR_ERROR;
109118
}
110119

0 commit comments

Comments
 (0)