Unix Programming - Re: how to set the socket parameters when the socket is created so that its file descr

This is Interesting: Free IT Magazines  
Home > Archive > Unix Programming > February 2007 > Re: how to set the socket parameters when the socket is created so that its file descr





You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

Author Re: how to set the socket parameters when the socket is created so that its file descr
Barry Margolin

2007-02-28, 1:22 am

In article <54kfrfF218mukU6@mid.individual.net>,
Ian Collins <ian-news@hotmail.com> wrote:

> sunny wrote:

There's no way to prevent sockets, or any other file descriptors, from
being inherited by forked processes. When you fork, the new process is
an exact duplicate of the parent, except for the PID and the return
value of the fork() system call.

If the child doesn't need to use the socket, it should close it after
fork() returns.
[vbcol=seagreen]
> Google for FD_CLOEXEC


That closes sockets only if the forked process calls exec().

--
Barry Margolin, barmar@alum.mit.edu
Arlington, MA
*** PLEASE post questions in newsgroups, not directly to me ***
*** PLEASE don't copy me on replies, I'll read them in the group ***
Sponsored Links






Free braindumps | Software forum | Database administration forum

Copyright 2003 - 2008 webservertalk.com