sp...@potato.field wrote:
> This flag when used with the socket() function is supposed to close all
> open sockets
Only the socket(s) for which it's set.
> when an exec() function is called. However it seems to do it when only
> fork() is called. Is this correct behaviour?
No, fork(2) is too early - you may call exec() afterwards, but
it shouldn't happen yet. There might be good reasons for keeping
it open in the newly spawned process (e.g. to communicate with
the parent process or if the parent spawned the new process for
minding what's happening on that socket and closes it itself).
As far as my understanding goes it should behave exactly as
O_CLOEXEC does when used with open(2) - and that definitely
closes the file only after an exec() and not on fork(2)
> Kernel version is 2.6.32.
That's a bit ancient now and short after it got introduced
(2.6.27 as far as I read), so perhaps there were stll some
issues back then (but it's a bit hard to believe since you
could set O_CLOEXEC on sockets before that, using fcntl(2),
just not at creation).
How did you come to the conclusion that the socket got already
closed after the fork()?
Regards, Jens
--
\ Jens Thoms Toerring ___
j...@toerring.de
\__________________________
http://toerring.de