# Skip _test_pty_eof() on systems where it hangs.
_tested_pty = True
+_fbsd_test_pty = platform.system() == 'FreeBSD'
+
def _create_pty_or_pipe(copy_term_size=None):
"""
Try to create a pty and if then fails then create a normal
got_pty = False
- global _disable_openpty, _tested_pty
+ global _disable_openpty, _fbsd_test_pty, _tested_pty
if not (_tested_pty or _disable_openpty):
try:
if not _test_pty_eof():
del e
_tested_pty = True
+ if _fbsd_test_pty and not _disable_openpty:
+ # Test for python openpty breakage after freebsd7 to freebsd8
+ # upgrade, which results in a 'Function not implemented' error
+ # and the process being killed.
+ pid = os.fork()
+ if pid == 0:
+ pty.openpty()
+ os._exit(os.EX_OK)
+ pid, status = os.waitpid(pid, 0)
+ if (status & 0xff) == 140:
+ _disable_openpty = True
+ _fbsd_test_pty = False
+
if _disable_openpty:
master_fd, slave_fd = os.pipe()
else: