From: Greg Ward Date: Tue, 11 Mar 2003 16:53:13 +0000 (+0000) Subject: Open with O_NONBLOCK to avoid hanging on open(). X-Git-Tag: v2.3c1~1480 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=5c49ef2116a12adf93ca626343fdcd1a5cc6af08;p=thirdparty%2FPython%2Fcpython.git Open with O_NONBLOCK to avoid hanging on open(). --- diff --git a/Modules/ossaudiodev.c b/Modules/ossaudiodev.c index 2f4693db56e9..077784088d1c 100644 --- a/Modules/ossaudiodev.c +++ b/Modules/ossaudiodev.c @@ -131,7 +131,11 @@ newossobject(PyObject *arg) basedev = "/dev/dsp"; } - if ((fd = open(basedev, imode)) == -1) { + /* Open with O_NONBLOCK to avoid hanging on devices that only allow + one open at a time. This does *not* affect later I/O; OSS + provides a special ioctl() for non-blocking read/write, which is + exposed via oss_nonblock() below. */ + if ((fd = open(basedev, imode|O_NONBLOCK)) == -1) { PyErr_SetFromErrnoWithFilename(PyExc_IOError, basedev); return NULL; }