@@ -43,14 +43,28 @@ The :mod:`pty` module defines the following functions:
43
43
44
44
Spawn a process, and connect its controlling terminal with the current
45
45
process's standard io. This is often used to baffle programs which insist on
46
- reading from the controlling terminal.
47
-
48
- The functions *master_read * and *stdin_read * are passed a file
49
- descriptor which they should read from, and should return a byte
50
- string. The default implementation for both functions will read up
51
- to 1024 bytes each time the function is called. Returning an empty
52
- byte string is interpreted as an end of file (EOF) condition, and
53
- that *_read * function will no longer be called.
46
+ reading from the controlling terminal. It is expected that the process
47
+ spawned behind the pty will eventually terminate, and when it does *spawn *
48
+ will return.
49
+
50
+ The functions *master_read * and *stdin_read * are passed a file descriptor
51
+ which they should read from, and they should always return a byte
52
+ string. Returning an empty byte string from either callback is interpreted as
53
+ an end-of-file (EOF) condition, and that callback will not be called after
54
+ that.
55
+
56
+ In general, manually signaling EOF from one of the read callback will not
57
+ behave well. If *stdin_read * returns EOF the controlling terminal can no
58
+ longer communicate with.
59
+
60
+ If both callbacks signal EOF then *spawn * will block indefinitely. This
61
+ is a bug, documented in `issue 26228 <https://bugs.python.org/issue26228 >`_.
62
+
63
+ The default implementation for both functions will read and return up to 1024
64
+ bytes each time the function is called. *Master_read * is passed the
65
+ pseudoterminal’s master file descriptor to read output from the child
66
+ process, and *stdin_read * is passed file descriptor 0, to read from the
67
+ parent process's standard input.
54
68
55
69
.. versionchanged :: 3.4
56
70
:func: `spawn ` now returns the status value from :func: `os.waitpid `
0 commit comments