2002-08-17 08:41:01 -03:00
|
|
|
# Helper script for test_tempfile.py. argv[2] is the number of a file
|
|
|
|
# descriptor which should _not_ be open. Check this by attempting to
|
|
|
|
# write to it -- if we succeed, something is wrong.
|
|
|
|
|
|
|
|
import sys
|
|
|
|
import os
|
2015-02-23 11:56:13 -04:00
|
|
|
from test.support import SuppressCrashReport
|
2002-08-17 08:41:01 -03:00
|
|
|
|
2015-02-23 11:56:13 -04:00
|
|
|
with SuppressCrashReport():
|
|
|
|
verbose = (sys.argv[1] == 'v')
|
2002-08-17 08:41:01 -03:00
|
|
|
try:
|
2015-02-23 11:56:13 -04:00
|
|
|
fd = int(sys.argv[2])
|
|
|
|
|
|
|
|
try:
|
|
|
|
os.write(fd, b"blat")
|
|
|
|
except OSError:
|
|
|
|
# Success -- could not write to fd.
|
|
|
|
sys.exit(0)
|
|
|
|
else:
|
|
|
|
if verbose:
|
|
|
|
sys.stderr.write("fd %d is open in child" % fd)
|
|
|
|
sys.exit(1)
|
|
|
|
|
|
|
|
except Exception:
|
2002-08-17 08:41:01 -03:00
|
|
|
if verbose:
|
2015-02-23 11:56:13 -04:00
|
|
|
raise
|
2002-08-17 08:41:01 -03:00
|
|
|
sys.exit(1)
|