Skip to content

Commit 92a024c

Browse files
committed
run: propagate errors when preforking
Signed-off-by: Giuseppe Scrivano <[email protected]>
1 parent de6338e commit 92a024c

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

src/libcrun/container.c

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1435,6 +1435,22 @@ libcrun_container_run (struct libcrun_context_s *context, libcrun_container *con
14351435
if (UNLIKELY (ret < 0))
14361436
return ret;
14371437

1438+
if (status < 0)
1439+
{
1440+
int errno_;
1441+
char buf[512];
1442+
ret = TEMP_FAILURE_RETRY (read (pipefd0, &errno_, sizeof (errno_)));
1443+
if (UNLIKELY (ret < 0))
1444+
return ret;
1445+
1446+
ret = TEMP_FAILURE_RETRY (read (pipefd0, buf, sizeof (buf) - 1));
1447+
if (UNLIKELY (ret < 0))
1448+
return ret;
1449+
buf[ret] = '\0';
1450+
1451+
return crun_make_error (err, errno_, buf);
1452+
}
1453+
14381454
return status;
14391455
}
14401456

@@ -1451,6 +1467,9 @@ libcrun_container_run (struct libcrun_context_s *context, libcrun_container *con
14511467
TEMP_FAILURE_RETRY (write (pipefd1, &ret, sizeof (ret)));
14521468
if (UNLIKELY (ret < 0))
14531469
{
1470+
TEMP_FAILURE_RETRY (write (pipefd1, &((*err)->status), sizeof ((*err)->status)));
1471+
TEMP_FAILURE_RETRY (write (pipefd1, (*err)->msg, strlen ((*err)->msg) + 1));
1472+
14541473
crun_set_output_handler (log_write_to_stderr, NULL);
14551474
libcrun_fail_with_error ((*err)->status, "%s", (*err)->msg);
14561475
}

0 commit comments

Comments
 (0)