1 #if HAVE_F_SETSIG && HAVE_F_SETAUXFL
2
3 #include "Poller_sigfd.h"
4 #include "dprint.h"
5 #include <unistd.h>
6 #include <fcntl.h>
7
8 /**
9 Add a file descriptor to the set we monitor.
10 Caller should already have established a handler for SIGIO.
11 @param fd file descriptor to add
12 @param client object to handle events for this fd. May use same client with more than one fd.
13 @param eventmask initial event mask for this fd
14 */
add(int fd,Client * client,short eventmask)15 int Poller_sigfd::add(int fd, Client *client, short eventmask)
16 {
17 int flags = O_ONESIGFD;
18 // FIXME: want to do GETAUXFL too if any other aux flags get defined
19 if (fcntl(fd, F_SETAUXFL, flags) < 0) {
20 int err = errno;
21 LOG_ERROR(("add: fcntl(fd %d, F_SETAUXFL, 0x%x) returns err %d\n",
22 fd, flags, err));
23 return err;
24 }
25 return Poller_sigio::add(fd, client, eventmask);
26 }
27
28 /// Remove a file descriptor.
del(int fd)29 int Poller_sigfd::del(int fd)
30 {
31 int flags = 0;
32 // FIXME: want to do GETAUXFL too if any other aux flags get defined
33 if (fcntl(fd, F_SETAUXFL, flags) < 0) {
34 int err = errno;
35 LOG_ERROR(("del: fcntl(fd %d, F_SETAUXFL, 0x%x) returns err %d\n",
36 fd, flags, err));
37 return err;
38 }
39 return Poller_sigio::del(fd);
40 }
41
42 #endif
43