Skip to content
This repository was archived by the owner on Feb 8, 2021. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions src/exec.c
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,6 @@ static int pts_loop(struct hyper_event *de, uint64_t seq, int efd, struct hyper_

do {
size = read(de->fd, buf->data + buf->get + 12, buf->size - buf->get - 12);
fprintf(stdout, "%s: read %d data\n", __func__, size);
if (size < 0) {
if (errno == EINTR)
continue;
Expand All @@ -122,6 +121,8 @@ static int pts_loop(struct hyper_event *de, uint64_t seq, int efd, struct hyper_

break;
}
fprintf(stdout, "%s: read %d data\n", __func__, size);

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

{ } is needed

if (size == 0) { // eof
pts_hup(de, efd, exec);
return 0;
Expand Down Expand Up @@ -544,13 +545,14 @@ static void hyper_exec_process(struct hyper_exec *exec, struct stdio_config *io)
}

if (execvp(exec->argv[0], exec->argv) < 0) {
// perror possibly changes the errno.
int err = errno;
perror("exec failed");

/* the exit codes follow the `chroot` standard,
see docker/docs/reference/run.md#exit-status */
if (errno == ENOENT)
if (err == ENOENT)
_exit(127);
else if (errno == EACCES)
else if (err == EACCES)
_exit(126);
}

Expand Down
4 changes: 2 additions & 2 deletions src/init.c
Original file line number Diff line number Diff line change
Expand Up @@ -1244,14 +1244,14 @@ static int hyper_loop(void)

while (1) {
n = epoll_pwait(ctl.efd, events, MAXEVENTS, -1, &omask);
fprintf(stdout, "%s epoll_wait %d\n", __func__, n);

if (n < 0) {
if (errno == EINTR)
continue;
perror("hyper wait event failed");
return -1;
}
fprintf(stdout, "%s epoll_wait %d\n", __func__, n);

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

{ } is needed

for (i = 0; i < n; i++) {
if (hyper_handle_event(ctl.efd, &events[i]) < 0)
return -1;
Expand Down
2 changes: 0 additions & 2 deletions src/net.c
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ int hyper_send_data(int fd, uint8_t *data, uint32_t len)

while (length < len) {
size = write(fd, data + length, len - length);

if (size <= 0) {
if (errno == EINTR)
continue;
Expand Down Expand Up @@ -99,7 +98,6 @@ int hyper_get_type(int fd, uint32_t *type)

while (len < 8) {
size = read(fd, buf + len, 8 - len);

if (size <= 0) {
if (errno == EINTR)
continue;
Expand Down
3 changes: 1 addition & 2 deletions src/util.c
Original file line number Diff line number Diff line change
Expand Up @@ -415,13 +415,12 @@ int hyper_open_channel(char *channel, int mode)
{
struct termios term;
int fd = open(channel, O_RDWR | O_CLOEXEC | mode);
fprintf(stdout, "open %s get %d\n", channel, fd);

if (fd < 0) {
perror("fail to open channel device");
return -1;
}

fprintf(stdout, "open %s get %d\n", channel, fd);
bzero(&term, sizeof(term));

cfmakeraw(&term);
Expand Down