Skip to content

Commit

Permalink
fix for hidden input
Browse files Browse the repository at this point in the history
  • Loading branch information
younix committed Nov 12, 2016
1 parent 4c9c337 commit 2fc68ac
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions fishii.c
Original file line number Diff line number Diff line change
Expand Up @@ -169,20 +169,22 @@ main(int argc, char *argv[])
if (pfd[0].revents & POLLIN) { /* in <- here <- plain/in */
char buf[PIPE_BUF + 1];

if ((n = read(plain_in, buf, PIPE_BUF)) == -1)
err(EXIT_FAILURE, "read");
if ((n = read(plain_in, buf, PIPE_BUF)) == -1) {
if (errno == EAGAIN)
continue;
err(EXIT_FAILURE, "read plain/in");
}

if (n == 0) { /* pipe was closed */
if (close(plain_in) == -1)
err(EXIT_FAILURE, "close");
if ((plain_in = open("plain/in", O_RDONLY|O_NONBLOCK)) == -1)
err(EXIT_FAILURE, "open");
pfd[0].fd = plain_in;
continue;
} else {
buf[n] = '\0';
handle_plain(buf, key);
}

buf[n] = '\0';
handle_plain(buf, key);
}

/* handle backend error and its broken pipe */
Expand Down

0 comments on commit 2fc68ac

Please sign in to comment.