summaryrefslogtreecommitdiffstats
path: root/misc/inherited-fds.ninja
diff options
context:
space:
mode:
authorEvan Martin <martine@danga.com>2011-10-31 22:39:03 (GMT)
committerEvan Martin <martine@danga.com>2011-10-31 22:39:53 (GMT)
commitbb52198d196ba294908abad00960783456e40f8b (patch)
treed337b9553256648609fbecde918342e654aa2543 /misc/inherited-fds.ninja
parenta6212990930c1ca85488bada1936ce41aac34364 (diff)
downloadNinja-bb52198d196ba294908abad00960783456e40f8b.zip
Ninja-bb52198d196ba294908abad00960783456e40f8b.tar.gz
Ninja-bb52198d196ba294908abad00960783456e40f8b.tar.bz2
don't leak fds into subprocesses
Patch from Antoine Labour <piman@chromium.org>, (hacky) test by me.
Diffstat (limited to 'misc/inherited-fds.ninja')
-rw-r--r--misc/inherited-fds.ninja23
1 files changed, 23 insertions, 0 deletions
diff --git a/misc/inherited-fds.ninja b/misc/inherited-fds.ninja
new file mode 100644
index 0000000..671155e
--- /dev/null
+++ b/misc/inherited-fds.ninja
@@ -0,0 +1,23 @@
+# This build file prints out a list of open file descriptors in
+# Ninja subprocesses, to help verify we don't accidentally leak
+# any.
+
+# Because one fd leak was in the code managing multiple subprocesses,
+# this test brings up multiple subprocesses and then dumps the fd
+# table of the last one.
+
+# Use like: ./ninja -f misc/inherited-fds.ninja
+
+rule sleep
+ command = sleep 10000
+
+rule dump
+ command = sleep 1; ls -l /proc/self/fd; exit 1
+
+build all: phony a b c d e
+
+build a: sleep
+build b: sleep
+build c: sleep
+build d: sleep
+build e: dump