More fun with file descriptors
Posted Jun 14, 2007 13:43 UTC (Thu) by
davecb (subscriber, #1574)
Parent article:
More fun with file descriptors
Odd, I recollect building apps which used high-numbered FDs
via a well-known idiom, below. I would expect that anyone
who needed to grab an FD for out-of-band use would use
something like
if (fstat(maxFd, &stat_buf) == -1) {
/* It's not in use, so grab it. */
if (fcntl(confFd, F_DUPFD, maxFd) != -1) {
/* Turns off FD_CLOEXEC as a sideffect. */
UTIL_CLOSE(confFd);
confFd = maxFd;
}
}
maxFd--;
Does that mean this ia not as well-known in the application-design world
as one would expect? It's the problem that motivated adding
fcntl(F_DUPFD) to the system, after all.
--dave
(
Log in to post comments)