oops, its unix specific, I use fork/execl.
In my child process I could do:
int fd_limit = sysconf(_SC_OPEN_MAX);
for (int i=3; i<fd_limit; i++) close(i);
to remove all open file descriptions, apart for stdin.stdout,stdout.
However If I only wanted to remove the socket based file
descriptors opened by the server, then its not clear how I would
do this.
Either I should record in some singleton, asio handle_accept
where the connection is created, but from what I have seen
in all the examples, closing in done explicitly and not in
connector destructor.
OR use fctrl() so that socket file descriptor are not copied on exce's.
Also I cant see any api to get hold of the file descriptor from a
ip::tcp::socket
It would be very useful to know how other people have
approached this issue.
Ta,
Avi
Post by Igor RPost by Avi BahraI have a ASIO based server. This server can spawn child process.
Is there any asio way of making sure that socket file
descriptors are not opened in any child process ?
Do you spawn it with fork() or just create another process?
You didn't tell what platform you use, but on Windows you can either
disable handle inheritance, when calling CreateProcess, or explicitly
call SetHandleInformation() on a specific socket descriptor.
------------------------------------------------------------------------------
All of the data generated in your IT infrastructure is seriously valuable.
Why? It contains a definitive record of application performance, security
threats, fraudulent activity, and more. Splunk takes this data and makes
sense of it. IT sense. And common sense.
http://p.sf.net/sfu/splunk-d2d-c2
_______________________________________________
asio-users mailing list
https://lists.sourceforge.net/lists/listinfo/asio-users
_______________________________________________
Using Asio? List your project at
http://think-async.com/Asio/WhoIsUsingAsio
--
Best regards,
Ta,
Avi