Skip to content
Open
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
26 changes: 13 additions & 13 deletions src/libcrun/container.c
Original file line number Diff line number Diff line change
Expand Up @@ -3274,20 +3274,20 @@ libcrun_container_create (libcrun_context_t *context, libcrun_container_t *conta
waitpid_ignore_stopped (ret, NULL, 0);

ret = TEMP_FAILURE_RETRY (read (pipefd0, &exit_code, sizeof (exit_code)));
if (UNLIKELY (ret < 0))
if (UNLIKELY (ret <= 0))
Copy link
Contributor

Choose a reason for hiding this comment

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

errno is not set if ret == 0

errno is used on line 3278

(typing on mobile phone)

return crun_make_error (err, errno, "waiting for container to be ready");
if (ret > 0)
{
if (exit_code != 0)
{
libcrun_debug ("Exit code is `%d`, deleting container", exit_code);
libcrun_error_t tmp_err = NULL;
libcrun_container_delete (context, def, context->id, true, &tmp_err);
crun_error_release (&tmp_err);
}
return -exit_code;
}
return 1;

if (ret != sizeof (exit_code) || exit_code < 0)
return crun_make_error (err, 0, "internal error: read invalid exit code");

if (exit_code == 0)
return 0;

libcrun_debug ("Exit code is `%d`, deleting container", exit_code);
libcrun_error_t tmp_err = NULL;
libcrun_container_delete (context, def, context->id, true, &tmp_err);
crun_error_release (&tmp_err);
return crun_make_error (err, 0, "error creating container");

Choose a reason for hiding this comment

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

medium

The error message is a bit generic. Including the exit_code from the container process would make it more informative for debugging purposes.

      return crun_make_error (err, 0, "error creating container: exit code %d", exit_code);

}

/* forked process. */
Expand Down