There is a potential race between enabling asynchronous IO and
selecting the target for the SIGIO signal. This changeset move the
F_SETOWN call to before the F_SETFL call that enables SIGIO
delivery. This ensures that signals are always sent to the correct
process.
else
flags &= ~(FASYNC);
- if (fcntl(fd, F_SETFL, flags) == -1)
- panic("Could not set up async IO");
-
if (set) {
if (fcntl(fd, F_SETOWN, getpid()) == -1)
panic("Could not set up async IO");
}
+
+ if (fcntl(fd, F_SETFL, flags) == -1)
+ panic("Could not set up async IO");
}
void