Nicolas Alvarez
2008-10-05 18:48:00 UTC
I have an application that currently uses plain BSD sockets for a custom
protocol, and libcurl for HTTP.
The application spawns also new processes via fork/exec. For its
self-created sockets, it calls fcntl(sock, F_SETFD, FD_CLOEXEC); to avoid
the spawned processes inheriting the socket. For the curl sockets, it
doesn't do anything special, and over time I see netstat output filling
with sockets in CLOSE_WAIT status, "owned" by the child processes (who have
no idea what to do with them).
I was considering moving it to asio (long term task). tcp::socket has
set_option (which calls setsockopt) and io_control (which calls ioctl), but
I don't see anything to call fcntl. Is there any way to call fcntl on an
asio socket? Or, is there a way to set a socket to "close on exec" using
set_option or io_control? Or, does asio already set this by default?
My other option, of course, would be to call fcntl directly, passing
socket.native(). Just wondering if asio already has a way to do this.
protocol, and libcurl for HTTP.
The application spawns also new processes via fork/exec. For its
self-created sockets, it calls fcntl(sock, F_SETFD, FD_CLOEXEC); to avoid
the spawned processes inheriting the socket. For the curl sockets, it
doesn't do anything special, and over time I see netstat output filling
with sockets in CLOSE_WAIT status, "owned" by the child processes (who have
no idea what to do with them).
I was considering moving it to asio (long term task). tcp::socket has
set_option (which calls setsockopt) and io_control (which calls ioctl), but
I don't see anything to call fcntl. Is there any way to call fcntl on an
asio socket? Or, is there a way to set a socket to "close on exec" using
set_option or io_control? Or, does asio already set this by default?
My other option, of course, would be to call fcntl directly, passing
socket.native(). Just wondering if asio already has a way to do this.