Project

General

Profile

How to set the FD_CLOEXEC flag on the socket for wthttpd

Added by Keith Stevens about 10 years ago

I'm working on a configurator web utility that updates some config files.

Currently it uses popen to exec stop of another server on embedded system, then writes

the config then uses popen to exec start of the other server. The other server

then starts several other child processes. All the processes started now listen

on the same port my app is on so I can't restart it. The fix - so far as I know,

is to set the FD_CLOEXEC flag on the file descriptor for the socket used by

wthttpd. Problem is I don't know how to get hold of that file descriptor. I searched

around on here but I'm either not keywording the right words or this hasn't come up

before. Anyone have any suggestions to solve this or work around it? Thanks.


Replies (2)

RE: How to set the FD_CLOEXEC flag on the socket for wthttpd - Added by Wim Dumon about 10 years ago

Hello,

This probably requires a change in src/http/Server.C. I assume you want to set this flag on the listener socket? That would be tcp_acceptor_ and ssl_acceptor_ in that file. Boost asio doesn't seem to support that particular option, but passing .native_handle() as socket to fcntl for those two sockets should do the trick.

BR,

Wim.

    (1-2/2)