1
0
mirror of https://github.com/systemd/systemd.git synced 2025-03-19 22:50:17 +03:00

util: add pipe_eof()

This commit is contained in:
Lennart Poettering 2011-05-23 23:54:00 +02:00
parent ab5c3e3ff1
commit 1325aa4202
2 changed files with 20 additions and 0 deletions

View File

@ -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;

View File

@ -357,6 +357,8 @@ int chmod_and_chown(const char *path, mode_t mode, uid_t uid, gid_t gid);
int rm_rf(const char *path, bool only_dirs, bool delete_root);
int pipe_eof(int fd);
cpu_set_t* cpu_set_malloc(unsigned *ncpus);
void status_vprintf(const char *format, va_list ap);