Bugzilla – Bug 815
waf shell file descriptor leak
Last modified: 2010-02-15 10:00:57 UTC
Created attachment 761 [details] possible fix A shared dev_null file is opened in waf-tools/shellcmd.py. The corresponding file descriptor remains open and is then inherited by child processes on some platforms. For example on linux: $ ./waf shell Waf: Entering directory `/home/jeos/ns-3-dev/build' Waf: Leaving directory `/home/jeos/ns-3-dev/build' $ ls -l /proc/self/fd total 0 lrwx------ 1 jeos jeos 64 2010-02-14 12:00 0 -> /dev/pts/1 lrwx------ 1 jeos jeos 64 2010-02-14 12:00 1 -> /dev/pts/1 lrwx------ 1 jeos jeos 64 2010-02-14 12:00 2 -> /dev/pts/1 lr-x------ 1 jeos jeos 64 2010-02-14 12:00 3 -> /proc/4112/fd l-wx------ 1 jeos jeos 64 2010-02-14 12:00 5 -> /dev/null Note fd 5. The attached patch sets the close-on-exec flag for dev_null when possible and should not effect platforms that don't have fcntl. A somewhat related comment: it might be easier to use os.devnull instead of choosing between "NUL:" and "/dev/null" in regression.py and waf-tools/shellcmd.py.
os.devnull does not exist in Python 2.3. Committed the patch, with minor modifications. Thanks!