summaryrefslogtreecommitdiff
path: root/Modules/ossaudiodev.c
diff options
context:
space:
mode:
authorGreg Ward <gward@python.net>2003-03-11 16:53:13 +0000
committerGreg Ward <gward@python.net>2003-03-11 16:53:13 +0000
commite12739c236cdadd7ebf2c1f1c82669d212abfeae (patch)
treedbb89e80c881fea70af2a84c3f9761bd16f4886a /Modules/ossaudiodev.c
parent10fc650e5820f5a713f1399974d49ecfaec4ee89 (diff)
downloadcpython-e12739c236cdadd7ebf2c1f1c82669d212abfeae.tar.gz
Open with O_NONBLOCK to avoid hanging on open().
Diffstat (limited to 'Modules/ossaudiodev.c')
-rw-r--r--Modules/ossaudiodev.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/Modules/ossaudiodev.c b/Modules/ossaudiodev.c
index 2f4693db56..077784088d 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;
}