about summary refs log tree commit homepage
diff options
context:
space:
mode:
authorEric Wong <e@80x24.org>2018-07-16 09:30:12 +0000
committerEric Wong <e@80x24.org>2018-07-16 19:33:12 +0000
commit834de3bc0da4af53535d5c9d4975e546df9fb186 (patch)
tree3c64c15a4600301e6138735596dbf2957a7b165a
parentfd9847c808c421a201ae574d93f6d0ea36d9ec63 (diff)
downloadmwrap-834de3bc0da4af53535d5c9d4975e546df9fb186.tar.gz
OK, Ruby blindly closing file descriptors it doesn't know about
is really getting on my nerves, now.
-rwxr-xr-xbin/mwrap7
1 files changed, 7 insertions, 0 deletions
diff --git a/bin/mwrap b/bin/mwrap
index 964fdf8..9f67dab 100755
--- a/bin/mwrap
+++ b/bin/mwrap
@@ -26,4 +26,11 @@ if ENV['MWRAP'] =~ /dump_fd:(\d+)/
     opts[dump_fd] = dump_io
   end
 end
+
+# allow inheriting FDs from systemd
+n = ENV['LISTEN_FDS']
+if n && ENV['LISTEN_PID'].to_i == $$
+  n = 3 + n.to_i
+  (3...n).each { |fd| opts[fd] = IO.new(fd) }
+end
 exec *ARGV, opts