summaryrefslogtreecommitdiff
path: root/src/util.c
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2011-05-23 23:54:00 +0200
committerLennart Poettering <lennart@poettering.net>2011-06-21 19:29:44 +0200
commit1325aa4202cbd393c9577794e2b4995cc8743892 (patch)
treef3b5529cb0adb43201f2fabc5f56ca78aa25763b /src/util.c
parentab5c3e3ff172e7dc295d3022170ee6a3be062a3f (diff)
util: add pipe_eof()
Diffstat (limited to 'src/util.c')
-rw-r--r--src/util.c18
1 files changed, 18 insertions, 0 deletions
diff --git a/src/util.c b/src/util.c
index 7f59021826..4a735dba58 100644
--- a/src/util.c
+++ b/src/util.c
@@ -4437,6 +4437,24 @@ char* hostname_cleanup(char *s) {
return s;
}
+int pipe_eof(int fd) {
+ struct pollfd pollfd;
+ int r;
+
+ zero(pollfd);
+ pollfd.fd = fd;
+ pollfd.events = POLLIN|POLLHUP;
+
+ r = poll(&pollfd, 1, 0);
+ if (r < 0)
+ return -errno;
+
+ if (r == 0)
+ return 0;
+
+ return pollfd.revents & POLLHUP;
+}
+
int terminal_vhangup_fd(int fd) {
if (ioctl(fd, TIOCVHANGUP) < 0)
return -errno;