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:
@@ -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 */
|
||||
|
||||
Reference in New Issue
Block a user