Skip to content

Commit c5879ba

Browse files
committed
container: make return clearer
the error is not set, so return a positive value to signal an exit code != 0. Closes: containers#1980 Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
1 parent ca0756f commit c5879ba

File tree

2 files changed

+8
-5
lines changed

2 files changed

+8
-5
lines changed

src/libcrun/container.c

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1577,10 +1577,13 @@ container_init (void *args, char *notify_socket, int sync_socket, libcrun_error_
15771577
{
15781578
/* If it fails to write the error using the sync socket, then fallback
15791579
to stderr. */
1580-
if (sync_socket_write_error (sync_socket, err) < 0)
1581-
return ret;
1582-
1583-
crun_error_release (err);
1580+
if (sync_socket_write_error (sync_socket, err) == 0)
1581+
{
1582+
crun_error_release (err);
1583+
/* A return value of > 0 means to fail with an error without err being set so to avoid
1584+
printing it twice. */
1585+
return 1;
1586+
}
15841587
return ret;
15851588
}
15861589

src/libcrun/linux.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5268,7 +5268,7 @@ libcrun_run_linux_container (libcrun_container_t *container, container_entrypoin
52685268
if (*err)
52695269
libcrun_fail_with_error ((*err)->status, "%s", (*err)->msg);
52705270

5271-
/* If cursor is here most likely we returned from a custom handler eg. wasm, libkrun */
5271+
/* If we got here likely we returned from a custom handler eg. wasm, libkrun */
52725272
/* Allow cleanup attributes to perform cleanup and exit with success if return code was 0 */
52735273
if (ret == 0)
52745274
_safe_exit (EXIT_SUCCESS);

0 commit comments

Comments
 (0)