diff options
author | Karel Zak | 2017-09-07 11:23:50 +0200 |
---|---|---|
committer | Karel Zak | 2017-09-18 11:49:11 +0200 |
commit | 5328d8e7e8dbb968ba2aa83f98cf132a14266483 (patch) | |
tree | 5dc34df2745d6a56186bda546a1d2e4c8c4d7ea4 /login-utils | |
parent | script: simplify stdin usage in poll() (diff) | |
download | kernel-qcow2-util-linux-5328d8e7e8dbb968ba2aa83f98cf132a14266483.tar.gz kernel-qcow2-util-linux-5328d8e7e8dbb968ba2aa83f98cf132a14266483.tar.xz kernel-qcow2-util-linux-5328d8e7e8dbb968ba2aa83f98cf132a14266483.zip |
su: (pty) simplify stdin usage in poll()
Not sure why I have problem with this years ago for script(1), but it
seems .fd=-1 is really enough to the ignore the FD.
Reported-by: Vaclav Dolezal <vdolezal@redhat.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
Diffstat (limited to 'login-utils')
-rw-r--r-- | login-utils/su-common.c | 11 |
1 files changed, 4 insertions, 7 deletions
diff --git a/login-utils/su-common.c b/login-utils/su-common.c index f873c23bc..bc96967be 100644 --- a/login-utils/su-common.c +++ b/login-utils/su-common.c @@ -442,11 +442,11 @@ static int pty_handle_signal(struct su_context *su, int fd) static void pty_proxy_master(struct su_context *su) { sigset_t ourset; - int rc = 0, ret, ignore_stdin = 0, eof = 0; + int rc = 0, ret, eof = 0; enum { POLLFD_SIGNAL = 0, POLLFD_MASTER, - POLLFD_STDIN /* optional; keep it last, see ignore_stdin */ + POLLFD_STDIN }; struct pollfd pfd[] = { @@ -490,7 +490,7 @@ static void pty_proxy_master(struct su_context *su) DBG(PTY, ul_debug("calling poll()")); /* wait for input or signal */ - ret = poll(pfd, ARRAY_SIZE(pfd) - ignore_stdin, su->poll_timeout); + ret = poll(pfd, ARRAY_SIZE(pfd), su->poll_timeout); errsv = errno; DBG(PTY, ul_debug("poll() rc=%d", ret)); @@ -505,7 +505,7 @@ static void pty_proxy_master(struct su_context *su) break; } - for (i = 0; i < ARRAY_SIZE(pfd) - ignore_stdin; i++) { + for (i = 0; i < ARRAY_SIZE(pfd); i++) { rc = 0; if (pfd[i].revents == 0) @@ -531,10 +531,7 @@ static void pty_proxy_master(struct su_context *su) if ((pfd[i].revents & POLLHUP) || eof) { DBG(PTY, ul_debug(" ignore FD")); pfd[i].fd = -1; - /* according to man poll() set FD to -1 can't be used to ignore - * STDIN, so let's remove the FD from pool at all */ if (i == POLLFD_STDIN) { - ignore_stdin = 1; write_eof_to_child(su); DBG(PTY, ul_debug(" ignore STDIN")); } |