We are using log4cpp in a process that controls and
manages other processes. When creating an appender to
stdout or stderr, those file descriptors get dup()
called on them to create copies. Since the close on
exec flag is not set on the new descriptors, after
forking and execing a seperate process, they remain
open. Since many times those descriptors are attached
to a tty, this can cause a controling terminal to hang
when exiting since it is still expecting i/o over an
open chanel.
This patch sets the close on exec flag for fd that gets
dup()ed. This seems to best solve our problem, but
perhaps there are those out there who rely on the fd
staying open on exec . . . I don't know why, but
perhaps. I'd like it to be incorprated into the next
release unless there are concerns or problems with
doing this (and please let me know if there are!).
Close-On-Exec after dup().