Bug 815 - waf shell file descriptor leak
waf shell file descriptor leak
Status: RESOLVED FIXED
Product: ns-3
Classification: Unclassified
Component: build system
ns-3-dev
All Linux
: P5 minor
Assigned To: ns-bugs
:
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2010-02-14 15:38 EST by Tom Goff
Modified: 2010-02-15 10:00 EST (History)
1 user (show)

See Also:


Attachments
possible fix (543 bytes, patch)
2010-02-14 15:38 EST, Tom Goff
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Tom Goff 2010-02-14 15:38:41 EST
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.
Comment 1 Gustavo J. A. M. Carneiro 2010-02-15 10:00:57 EST
os.devnull does not exist in Python 2.3.

Committed the patch, with minor modifications.  Thanks!