aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2017-04-11 16:11:51 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2017-04-11 16:11:51 +0200
commit50579107e3f628c2e3c644d5af01ef67404a0f2a (patch)
treedf1c72b7bd6478a0676c573db9ef619e8610be4c
parentf38fa3d9a5ee0ab92ac6c8b07b935724bbbcef1e (diff)
Close sockets on exec
-rw-r--r--bbot/agent.cxx2
-rw-r--r--bbot/machine.cxx2
-rw-r--r--bbot/tftp.cxx2
-rw-r--r--bbot/worker.cxx7
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.
//