1
0
mirror of https://github.com/Interlisp/maiko.git synced 2026-02-23 15:42:17 +00:00

fcntl(..., F_SETFL, ...) return value only signals error. (#141)

The return value of `fcntl` when passed `F_SETFL` isn't guaranteed
to return the flags passed in as its return value. It will be `-1`
in the event of an error, but no other value is to be relied upon.

Fortunately, we weren't relying upon the value apart from
occasionally checking for an error.

This is as it is specified in https://pubs.opengroup.org/onlinepubs/7908799/xsh/fcntl.html

Closes interlisp/medley#87.
This commit is contained in:
Bruce Mitchener
2020-12-29 08:59:27 +07:00
committed by GitHub
parent 01926fc232
commit 3e2a2d76ec
8 changed files with 21 additions and 25 deletions

View File

@@ -78,7 +78,6 @@ LispPTR CHAR_openfile(LispPTR *args)
#ifndef DOS
register int fd; /* return value of open system call. */
register int flags; /* open system call's argument */
register int rval;
struct stat statbuf;
char pathname[MAXPATHLEN];
@@ -104,9 +103,7 @@ LispPTR CHAR_openfile(LispPTR *args)
}
/* Prevent I/O requests from blocking -- make them error */
/* if no char is available, or there's no room in pipe. */
rval = fcntl(fd, F_GETFL, 0);
rval |= FNDELAY;
rval = fcntl(fd, F_SETFL, rval);
fcntl(fd, F_SETFL, fcntl(fd, F_GETFL, 0) | FNDELAY);
return (GetSmallp(fd));
#endif /* DOS */