Skip to content
This repository was archived by the owner on Feb 8, 2021. It is now read-only.

Commit a615be8

Browse files
committed
directly hangup the event when read/write-error on process's stdio
Signed-off-by: Lai Jiangshan <[email protected]>
1 parent 4fc7ddd commit a615be8

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

src/exec.c

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -115,8 +115,9 @@ static int pts_loop(struct hyper_event *de, uint64_t seq, int efd, struct hyper_
115115
continue;
116116

117117
if (errno != EAGAIN && errno != EIO) {
118-
perror("fail to read tty fd");
119-
return -1;
118+
perror("failed to read process's stdout/stderr");
119+
pts_hup(de, efd, exec);
120+
return 0;
120121
}
121122

122123
break;
@@ -152,12 +153,10 @@ static int write_to_stdin(struct hyper_event *de, int efd)
152153
struct hyper_exec *exec = container_of(de, struct hyper_exec, stdinev);
153154
fprintf(stdout, "%s, seq %" PRIu64"\n", __func__, exec->seq);
154155

155-
int ret = hyper_event_write(de, efd);
156-
157-
if (ret >= 0 && de->wbuf.get == 0 && exec->close_stdin_request)
156+
if (hyper_event_write(de, efd) < 0 || (de->wbuf.get == 0 && exec->close_stdin_request))
158157
pts_hup(de, efd, exec);
159158

160-
return ret;
159+
return 0;
161160
}
162161

163162
struct hyper_event_ops in_ops = {

0 commit comments

Comments
 (0)