Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitd08fd29

Browse files
bpo-38547: Fix test_pty if the process is the session leader (GH-17519)
Fix test_pty: if the process is the session leader, closing themaster file descriptor raises a SIGHUP signal: simply ignore SIGHUPwhen running the tests.(cherry picked from commita1838ec)Co-authored-by: Victor Stinner <vstinner@python.org>
1 parent4594565 commitd08fd29

File tree

2 files changed

+19
-3
lines changed

2 files changed

+19
-3
lines changed

‎Lib/test/test_pty.py‎

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -66,16 +66,27 @@ def _readline(fd):
6666
# XXX(nnorwitz): these tests leak fds when there is an error.
6767
classPtyTest(unittest.TestCase):
6868
defsetUp(self):
69-
# isatty() and close() can hang on some platforms. Set an alarm
70-
# before running the test to make sure we don't hang forever.
7169
old_alarm=signal.signal(signal.SIGALRM,self.handle_sig)
7270
self.addCleanup(signal.signal,signal.SIGALRM,old_alarm)
71+
72+
old_sighup=signal.signal(signal.SIGHUP,self.handle_sighup)
73+
self.addCleanup(signal.signal,signal.SIGHUP,old_alarm)
74+
75+
# isatty() and close() can hang on some platforms. Set an alarm
76+
# before running the test to make sure we don't hang forever.
7377
self.addCleanup(signal.alarm,0)
7478
signal.alarm(10)
7579

7680
defhandle_sig(self,sig,frame):
7781
self.fail("isatty hung")
7882

83+
@staticmethod
84+
defhandle_sighup(sig,frame):
85+
# if the process is the session leader, os.close(master_fd)
86+
# of "master_fd, slave_name = pty.master_open()" raises SIGHUP
87+
# signal: just ignore the signal.
88+
pass
89+
7990
deftest_basic(self):
8091
try:
8192
debug("Calling master_open()")
@@ -122,9 +133,11 @@ def test_basic(self):
122133
self.assertEqual(b'For my pet fish, Eric.\n',normalize_output(s2))
123134

124135
os.close(slave_fd)
136+
# closing master_fd can raise a SIGHUP if the process is
137+
# the session leader: we installed a SIGHUP signal handler
138+
# to ignore this signal.
125139
os.close(master_fd)
126140

127-
128141
deftest_fork(self):
129142
debug("calling pty.fork()")
130143
pid,master_fd=pty.fork()
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
Fix test_pty: if the process is the session leader, closing the master file
2+
descriptor raises a SIGHUP signal: simply ignore SIGHUP when running the
3+
tests.

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2026 Movatter.jp