From 50579107e3f628c2e3c644d5af01ef67404a0f2a Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Tue, 11 Apr 2017 16:11:51 +0200 Subject: Close sockets on exec --- bbot/agent.cxx | 2 +- bbot/machine.cxx | 2 +- bbot/tftp.cxx | 2 +- bbot/worker.cxx | 7 ++++++- 4 files changed, 9 insertions(+), 4 deletions(-) diff --git a/bbot/agent.cxx b/bbot/agent.cxx index 8a47483..4d5cc4a 100644 --- a/bbot/agent.cxx +++ b/bbot/agent.cxx @@ -55,7 +55,7 @@ namespace bbot if (i.size () >= IFNAMSIZ) throw invalid_argument ("interface nama too long"); - auto_fd fd (socket (AF_INET, SOCK_DGRAM, 0)); + auto_fd fd (socket (AF_INET, SOCK_DGRAM | SOCK_CLOEXEC, 0)); if (fd.get () == -1) throw_system_error (errno); diff --git a/bbot/machine.cxx b/bbot/machine.cxx index 94a81ab..8cad3f9 100644 --- a/bbot/machine.cxx +++ b/bbot/machine.cxx @@ -257,7 +257,7 @@ namespace bbot addr.sun_family = AF_LOCAL; strcpy (addr.sun_path, monitor.string ().c_str ()); // Size check in ctor - auto_fd sock (socket (AF_LOCAL, SOCK_STREAM, 0)); + auto_fd sock (socket (AF_LOCAL, SOCK_STREAM | SOCK_CLOEXEC, 0)); if (sock.get () == -1) throw_system_error (errno); diff --git a/bbot/tftp.cxx b/bbot/tftp.cxx index b47eef4..9c783c5 100644 --- a/bbot/tftp.cxx +++ b/bbot/tftp.cxx @@ -21,7 +21,7 @@ namespace bbot tftp_server:: tftp_server (const string& map) { - int fd (socket (AF_INET, SOCK_DGRAM, 0)); + int fd (socket (AF_INET, SOCK_DGRAM | SOCK_CLOEXEC, 0)); if (fd == -1) throw_system_error (errno); diff --git a/bbot/worker.cxx b/bbot/worker.cxx index 07d92c3..e0149fc 100644 --- a/bbot/worker.cxx +++ b/bbot/worker.cxx @@ -22,6 +22,11 @@ using namespace std; using namespace butl; using namespace bbot; +namespace bbot +{ + worker_options ops; +} + int main (int argc, char* argv[]) try @@ -62,7 +67,7 @@ try #endif cli::argv_scanner scan (argc, argv, true); - worker_options ops (scan); + ops.parse (scan); // Version. // -- cgit v1.1