gh-154227: Fix os.posix_openpt() on OpenBSD (GH-154228) · python/cpython@d01b90c

GitHub

Original file line numberDiff line numberDiff line change@@ -0,0 +1,2 @@

1+Fix :func:`os.posix_openpt` on OpenBSD, where it rejected the

2+:data:`~os.O_CLOEXEC` flag.

Original file line numberDiff line numberDiff line change@@ -9186,7 +9186,9 @@ os_posix_openpt_impl(PyObject *module, int oflag)

91869186{

91879187 int fd;

918891889189-#if defined(O_CLOEXEC)

9189+ // OpenBSD posix_openpt() rejects any flag other than O_RDWR and

9190+ // O_NOCTTY; the fd is made non-inheritable below in any case.

9191+#if defined(O_CLOEXEC) && !defined(__OpenBSD__)

91909192 oflag |= O_CLOEXEC;

91919193#endif

91929194