mirror of
https://github.com/Interlisp/maiko.git
synced 2026-01-26 11:52:25 +00:00
Update fcntl F_SETFL usage. (#144)
This changes from `FASYNC` to `O_ASYNC`, `FNDELAY` to `O_NONBLOCK`, and `O_NDELAY` to `O_NONBLOCK`. These are the modern names. `O_NONBLOCK` is part of the POSIX standard. However, `O_ASYNC` is specific to Linux and BSD. It is not available on Solaris, where we still need to use `FASYNC`. Also, the behavior of having I/O trigger a `SIGIO` signal is not in POSIX, since the `SIGIO` signal is not in POSIX. Instead, it is only the behavior of having `SIGURG` being signalled for out of band data that is specified. We also takes this opportunity to collapse some multi-line calls to get the flags, store it into a temp, and then set them, to just doing it in one line, skipping the stored temporary value. We also change one instance of `65535 - FNDELAY` to `~O_NONBLOCK`. Closes interlisp/medley#85.
This commit is contained in:
@@ -76,7 +76,6 @@ char filetorun[30] = "lde";
|
||||
int main(int argc, char *argv[]) {
|
||||
char Earg[30], Ename[30], **newargv;
|
||||
int i;
|
||||
int flags;
|
||||
#ifdef USE_DLPI
|
||||
static struct packetfilt pf = {0, 1, {ENF_PUSHZERO}};
|
||||
struct strioctl si;
|
||||
@@ -129,8 +128,7 @@ int main(int argc, char *argv[]) {
|
||||
return (-1);
|
||||
}
|
||||
|
||||
flags = fcntl(ether_fd, F_GETFL, 0);
|
||||
fcntl(ether_fd, F_SETFL, flags | O_NDELAY);
|
||||
fcntl(ether_fd, F_SETFL, fcntl(ether_fd, F_GETFL, 0) | O_NONBLOCK);
|
||||
|
||||
#else
|
||||
/* N O T D L P I C O D E */
|
||||
@@ -210,8 +208,7 @@ int main(int argc, char *argv[]) {
|
||||
bcopy(if_data.ifc_req[0].ifr_addr.sa_data, ether_host, 6);
|
||||
strcpy(Ename, if_data.ifc_req[0].ifr_name);
|
||||
|
||||
flags = fcntl(ether_fd, F_GETFL, 0);
|
||||
fcntl(ether_fd, F_SETFL, flags | FASYNC | FNDELAY);
|
||||
fcntl(ether_fd, F_SETFL, fcntl(ether_fd, F_GETFL, 0) | O_ASYNC | O_NONBLOCK);
|
||||
|
||||
#endif /* USE_DLPI */
|
||||
#ifdef DEBUG
|
||||
|
||||
Reference in New Issue
Block a user