summaryrefslogtreecommitdiff
path: root/hw/xfree86/os-support/shared/sigio.c
diff options
context:
space:
mode:
authorPeter Hutterer <peter.hutterer@who-t.net>2009-05-28 17:20:58 +1000
committerPeter Hutterer <peter.hutterer@who-t.net>2009-05-28 17:20:58 +1000
commitd7aef3f663f4b5d861799f8615dcd301d5ce2906 (patch)
tree3a5ed1b3dc7e83536979578e3da99f2860f44b11 /hw/xfree86/os-support/shared/sigio.c
parenta25f248fc3bd0375d91ca8a44320200d445ecfbb (diff)
parente08c6a0752772745f35f7afcf6c2b1c927b91cc0 (diff)
Merge branch 'master' into xi2
Conflicts: Xext/geext.c Xi/chdevcur.c Xi/extgrbdev.c Xi/xiproperty.c configure.ac dix/ptrveloc.c hw/xfree86/common/xf86Config.c mi/mipointer.h test/input.c xkb/xkb.c
Diffstat (limited to 'hw/xfree86/os-support/shared/sigio.c')
-rw-r--r--hw/xfree86/os-support/shared/sigio.c42
1 files changed, 36 insertions, 6 deletions
diff --git a/hw/xfree86/os-support/shared/sigio.c b/hw/xfree86/os-support/shared/sigio.c
index 54c02cc8e..5ba0b7e1c 100644
--- a/hw/xfree86/os-support/shared/sigio.c
+++ b/hw/xfree86/os-support/shared/sigio.c
@@ -63,6 +63,10 @@
# include "xf86_OSlib.h"
# include "inputstr.h"
+#ifdef HAVE_STROPTS_H
+# include <stropts.h>
+#endif
+
/*
* Linux libc5 defines FASYNC, but not O_ASYNC. Don't know if it is
* functional or not.
@@ -139,6 +143,7 @@ xf86InstallSIGIOHandler(int fd, void (*f)(int, void *), void *closure)
struct sigaction osa;
int i;
int blocked;
+ int installed = FALSE;
for (i = 0; i < MAX_FUNCS; i++)
{
@@ -147,15 +152,30 @@ xf86InstallSIGIOHandler(int fd, void (*f)(int, void *), void *closure)
if (xf86IsPipe (fd))
return 0;
blocked = xf86BlockSIGIO();
+#ifdef O_ASYNC
if (fcntl(fd, F_SETFL, fcntl(fd, F_GETFL) | O_ASYNC) == -1) {
- xf86Msg(X_WARNING, "fcntl(%d, O_ASYNC): %s\n",
+ xf86Msg(X_WARNING, "fcntl(%d, O_ASYNC): %s\n",
fd, strerror(errno));
- xf86UnblockSIGIO(blocked);
- return 0;
+ } else {
+ if (fcntl(fd, F_SETOWN, getpid()) == -1) {
+ xf86Msg(X_WARNING, "fcntl(%d, F_SETOWN): %s\n",
+ fd, strerror(errno));
+ } else {
+ installed = TRUE;
+ }
}
- if (fcntl(fd, F_SETOWN, getpid()) == -1) {
- xf86Msg(X_WARNING, "fcntl(%d, F_SETOWN): %s\n",
- fd, strerror(errno));
+#endif
+#ifdef I_SETSIG /* System V Streams - used on Solaris for input devices */
+ if (!installed && isastream(fd)) {
+ if (ioctl(fd, I_SETSIG, S_INPUT | S_ERROR | S_HANGUP) == -1) {
+ xf86Msg(X_WARNING, "fcntl(%d, I_SETSIG): %s\n",
+ fd, strerror(errno));
+ } else {
+ installed = TRUE;
+ }
+ }
+#endif
+ if (!installed) {
xf86UnblockSIGIO(blocked);
return 0;
}
@@ -221,7 +241,17 @@ xf86RemoveSIGIOHandler(int fd)
}
if (ret)
{
+#ifdef O_ASYNC
fcntl(fd, F_SETFL, fcntl(fd, F_GETFL) & ~O_ASYNC);
+#endif
+#ifdef I_SETSIG
+ if (isastream(fd)) {
+ if (ioctl(fd, I_SETSIG, 0) == -1) {
+ xf86Msg(X_WARNING, "fcntl(%d, I_SETSIG, 0): %s\n",
+ fd, strerror(errno));
+ }
+ }
+#endif
xf86SigIOMax = max;
xf86SigIOMaxFd = maxfd;
if (!max)