~justin-fathomdb/nova/justinsb-openstack-api-volumes

« back to all changes in this revision

Viewing changes to vendor/Twisted-10.0.0/twisted/test/process_fds.py

  • Committer: Jesse Andrews
  • Date: 2010-05-28 06:05:26 UTC
  • Revision ID: git-v1:bf6e6e718cdc7488e2da87b21e258ccc065fe499
initial commit

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
 
 
2
"""Write to a handful of file descriptors, to test the childFDs= argument of
 
3
reactor.spawnProcess()
 
4
"""
 
5
 
 
6
import os, sys
 
7
 
 
8
debug = 0
 
9
 
 
10
if debug: stderr = os.fdopen(2, "w")
 
11
 
 
12
if debug: print >>stderr, "this is stderr"
 
13
 
 
14
abcd = os.read(0, 4)
 
15
if debug: print >>stderr, "read(0):", abcd
 
16
if abcd != "abcd":
 
17
    sys.exit(1)
 
18
 
 
19
if debug: print >>stderr, "os.write(1, righto)"
 
20
 
 
21
os.write(1, "righto")
 
22
 
 
23
efgh = os.read(3, 4)
 
24
if debug: print >>stderr, "read(3):", efgh
 
25
if efgh != "efgh":
 
26
    sys.exit(2)
 
27
 
 
28
if debug: print >>stderr, "os.close(4)"
 
29
os.close(4)
 
30
 
 
31
eof = os.read(5, 4)
 
32
if debug: print >>stderr, "read(5):", eof
 
33
if eof != "":
 
34
    sys.exit(3)
 
35
 
 
36
if debug: print >>stderr, "os.write(1, closed)"
 
37
os.write(1, "closed")
 
38
 
 
39
if debug: print >>stderr, "sys.exit(0)"
 
40
sys.exit(0)