Skip to content

Commit 2e66c1c

Browse files
authored
Merge pull request containers#551 from jnovy/pollfix
Handle descriptor in non-blocking mode properly.
2 parents 82de887 + 5412374 commit 2e66c1c

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/ctr_stdio.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,10 @@ static bool read_stdio(int fd, stdpipe_t pipe, gboolean *eof)
129129
*eof = true;
130130
return false;
131131
} else if (num_read < 0) {
132+
if (errno == EAGAIN || errno == EWOULDBLOCK) {
133+
// Non-blocking mode - no data available, return gracefully
134+
return true;
135+
}
132136
/* Ignore EIO if fd is a tty, since this can happen when the tty is closed
133137
while we are reading from it. */
134138
if (errno == EIO && isatty(fd)) {
@@ -144,7 +148,7 @@ static bool read_stdio(int fd, stdpipe_t pipe, gboolean *eof)
144148

145149
bool written = write_to_logs(pipe, buf, num_read);
146150
if (!written)
147-
return written;
151+
return false;
148152

149153
real_buf[0] = pipe;
150154
write_back_to_remote_consoles(real_buf, num_read + 1);

0 commit comments

Comments
 (0)