Independence of file descriptor flags across forks (or lack thereof)

Steve O'Hara-Smith steve at sohara.org
Wed Jan 8 11:42:58 UTC 2020


On Wed, 08 Jan 2020 01:10:19 -0800
"Ronald F. Guilmette" <rfg at tristatelogic.com> wrote:

> Quite simply, I started some development work recently with the
> (apparently naive) belief that when a process forks, and its child
> process get its own "independent" copy of all of the file descriptors

	It does - but file descriptors are just integers - see the open
manpage.

> that are currently open in the parent process, the child would also get
> its own independent copy of the system-maintained "flags word" for each
> of those inherited file descriptor copies.

	The fork manpage tells you that the descriptors reference the same
underlying object. It is that object (the open file) which holds the "flags
word".

> So dear friends, I must ask you, am I delusional?  Is this all just some
> massive misunderstanding on my part?

	Yep.

-- 
Steve O'Hara-Smith <steve at sohara.org>


More information about the freebsd-questions mailing list