MCPcopy Index your code
hub / github.com/nodejs/node / pipe

Function pipe

tools/pseudo-tty.py:16–44  ·  view source on GitHub ↗
(sfd, dfd)

Source from the content-addressed store, hash-verified

14
15
16def pipe(sfd, dfd):
17 try:
18 data = os.read(sfd, 256)
19 except OSError as e:
20 if e.errno != errno.EIO:
21 raise
22 return True # EOF
23
24 if not data:
25 return True # EOF
26
27 if dfd == STDOUT:
28 # Work around platform quirks. Some platforms echo ^D as \x04
29 # (AIX, BSDs) and some don't (Linux).
30 #
31 # The comparison against b' '[0] is because |data| is
32 # a string in python2 but a bytes object in python3.
33 filt = lambda c: c >= b' '[0] or c in b'\t\n\r\f'
34 data = filter(filt, data)
35 data = bytes(data)
36
37 while data:
38 try:
39 n = os.write(dfd, data)
40 except OSError as e:
41 if e.errno != errno.EIO:
42 raise
43 return True # EOF
44 data = data[n:]
45
46
47if __name__ == '__main__':

Callers 1

pseudo-tty.pyFile · 0.70

Calls 4

filterFunction · 0.50
bytesFunction · 0.50
readMethod · 0.45
writeMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…