From: Michalis Pappas Date: Sun, 30 Mar 2025 13:43:29 +0000 (+0200) Subject: lib/posix-process: Update semantics of vfork()'s return type X-Git-Url: http://xenbits.xensource.com/gitweb?a=commitdiff_plain;h=08c6ac9b0ffd8d313dcd2a38e94665974d8481c8;p=unikraft%2Funikraft.git lib/posix-process: Update semantics of vfork()'s return type Although with the current implementation the returned value is identical, vfork() returns the child's pid rather than tid. Updadte the naming of identifiers to reflect that correctly. Signed-off-by: Michalis Pappas Approved-by: Andrei Tatar Reviewed-by: Sergiu Moga Reviewed-by: Andrei Tatar GitHub-Closes: #1627 --- diff --git a/lib/posix-process/clone.c b/lib/posix-process/clone.c index e74f80dec..29138fef5 100644 --- a/lib/posix-process/clone.c +++ b/lib/posix-process/clone.c @@ -558,8 +558,8 @@ int uk_clone(struct clone_args *cl_args, size_t cl_args_len, uk_thread_set_runnable(child); - /* We will return the child's thread ID in the parent */ - ret = ukthread2tid(child); + /* We will return the child's pid to the parent */ + ret = ukthread2pid(child); /* Assign the child to the scheduler */ uk_sched_thread_add(s, child); diff --git a/lib/posix-process/vfork.c b/lib/posix-process/vfork.c index 733d2228d..4ec3da9a4 100644 --- a/lib/posix-process/vfork.c +++ b/lib/posix-process/vfork.c @@ -18,21 +18,17 @@ UK_LLSYSCALL_R_E_DEFINE(pid_t, vfork) { - struct posix_process *child_proc; struct clone_args cl_args = {0}; - pid_t child_tid; + pid_t pid; /* child */ cl_args.flags = CLONE_VM | CLONE_VFORK; cl_args.exit_signal = SIGCHLD; - child_tid = uk_clone(&cl_args, sizeof(cl_args), execenv); - if (unlikely(child_tid < 0)) { - uk_pr_err("Could not clone thread\n"); - return child_tid; + pid = uk_clone(&cl_args, sizeof(cl_args), execenv); + if (unlikely(pid < 0)) { + uk_pr_err("vfork error (%d)\n", pid); + return pid; } - child_proc = tid2pprocess(child_tid); - UK_ASSERT(child_proc); - - return child_proc->pid; + return pid; }