summaryrefslogtreecommitdiffstats
path: root/libdaemon/dnonblock.c
diff options
context:
space:
mode:
Diffstat (limited to 'libdaemon/dnonblock.c')
-rw-r--r--libdaemon/dnonblock.c13
1 files changed, 7 insertions, 6 deletions
diff --git a/libdaemon/dnonblock.c b/libdaemon/dnonblock.c
index b93d875..c16d511 100644
--- a/libdaemon/dnonblock.c
+++ b/libdaemon/dnonblock.c
@@ -27,17 +27,18 @@
#include "dnonblock.h"
int daemon_nonblock(int fd, int b) {
- int a;
+ int a, c;
+
if ((a = fcntl(fd, F_GETFL)) < 0)
return -1;
if (b)
- a |= O_NDELAY;
+ c = a | O_NDELAY;
else
- a &= ~O_NDELAY;
+ c = a & ~O_NDELAY;
- if (fcntl(fd, F_SETFL, a) < 0)
- return -1;
+ if (c == a)
+ return 0;
- return 0;
+ return fcntl(fd, F_SETFL, a);
}