Skip to content

Commit 6f16e5d

Browse files
committed
libcrun: document vfork shared error
There are examples in the source code where the vfork parent process reuses an error created by the vfork child process. Document that there is no need to create an error in the parent process in such cases. Related issue: containers#2015 Amended the suggestion from gemini-code-assist in containers#2018 with some modifications. Signed-off-by: Erik Sjölund <erik.sjolund@gmail.com>
1 parent 94fda0b commit 6f16e5d

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

src/libcrun/linux.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6216,6 +6216,8 @@ run_in_container_namespace (libcrun_container_status_t *status, int (*callback)
62166216
if (UNLIKELY (ret < 0))
62176217
return crun_make_error (err, errno, "waitpid for exec child pid");
62186218

6219+
/* Since vfork() is used, the child process shares the parent's memory.
6220+
* This allows the parent to reuse the error created by the child. */
62196221
return get_process_exit_status (wait_status);
62206222
}
62216223

src/libcrun/net_device.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -484,7 +484,12 @@ move_network_device (const char *ifname, const char *newifname, int netns_fd, li
484484
return crun_make_error (err, errno, "waitpid for exec child pid");
485485

486486
if (wait_status != 0)
487-
return -get_process_exit_status (wait_status);
487+
{
488+
489+
/* Since vfork() is used, the child process shares the parent's memory.
490+
* This allows the parent to reuse the error created by the child. */
491+
return -get_process_exit_status (wait_status);
492+
}
488493

489494
return 0;
490495
}

0 commit comments

Comments
 (0)