Converting USG UNIX programs to Berk - (nf)

jab at uokvax.UUCP jab at uokvax.UUCP
Sat Feb 18 14:10:52 AEST 1984


#R:hou2b:-21100:uokvax:6200019:000:972
uokvax!jab    Feb 16 17:45:00 1984

/***** uokvax:net.unix-wizar / hou2b!wcs / 12:15 am  Feb 14, 1984 */
I'm trying to convert a large software package to 4.1BSD, and I'm
having problems with open() and fcntl() system calls.

The fcntl() function provides several features: F_DUPFD, which I can
duplicate using dup2(), and F_SETFD, which I don't understand at
all.  It sets a "close_on_exec" flag associated with the file
descriptor, which has something to do with closing the file after an
exec or fork.
/* ---------- */

The "close on exec" flag can be set via the Berkeley ioctl call:
	ioctl(fd, FIOCLEX, 0);
This causes "fd" to be not stay open across the exec system call,
and is for opening files that you don't want to be available to the
next program. (Really, it's kinda handy for things like file
descriptors you want saved between calls, like for a database or
password hash file, but don't care about giving to the next process
you run --- let it open up its own files!)

	Jeff Bowles
	Lisle, IL



More information about the Comp.unix.wizards mailing list