]> xenbits.xensource.com Git - unikraft/unikraft.git/commitdiff
lib/posix-process: Update semantics of vfork()'s return type
authorMichalis Pappas <michalis@unikraft.io>
Sun, 30 Mar 2025 13:43:29 +0000 (15:43 +0200)
committerUnikraft Bot <monkey@unikraft.io>
Wed, 30 Apr 2025 09:42:51 +0000 (09:42 +0000)
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 <michalis@unikraft.io>
Approved-by: Andrei Tatar <andrei@unikraft.io>
Reviewed-by: Sergiu Moga <sergiu@unikraft.io>
Reviewed-by: Andrei Tatar <andrei@unikraft.io>
GitHub-Closes: #1627

lib/posix-process/clone.c
lib/posix-process/vfork.c

index e74f80decf68553dff02821bf96f7ffc87448040..29138fef569b8ec0c53d4af224d1967a04716a49 100644 (file)
@@ -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);
index 733d2228d2ed30b2a85b699ba28cabafa23ec3a3..4ec3da9a4cba65aa67492e399c178baaf803c6fb 100644 (file)
 
 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;
 }