From: Michalis Pappas Date: Tue, 16 Apr 2024 09:44:51 +0000 (+0200) Subject: lib/posix-process: Add posix_thread parent X-Git-Url: http://xenbits.xensource.com/gitweb?a=commitdiff_plain;h=8eb6c29d545758d70bb381c8ad63ece9715b3256;p=unikraft%2Funikraft.git lib/posix-process: Add posix_thread parent Add a field to posix_thread to keep track of its parent. This is populated during the creation of a posix_thread, and it is used for deriving the parent's state in execve() / exit(). Signed-off-by: Michalis Pappas Approved-by: Andrei Tatar Reviewed-by: Sergiu Moga Reviewed-by: Andrei Tatar GitHub-Closes: #1386 --- diff --git a/lib/posix-process/process.c b/lib/posix-process/process.c index fbc85d6f9..f3aed6f40 100644 --- a/lib/posix-process/process.c +++ b/lib/posix-process/process.c @@ -33,6 +33,7 @@ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. */ + #include #include #include @@ -250,6 +251,8 @@ int uk_posix_process_create(struct uk_alloc *a, pprocess_release(orig_pprocess); } + (*pthread)->parent = parent_pthread; + pprocess->parent = parent_pprocess; if (parent_pprocess) { uk_list_add_tail(&pprocess->child_list_entry, diff --git a/lib/posix-process/process.h b/lib/posix-process/process.h index 0e60fe371..fb313e059 100644 --- a/lib/posix-process/process.h +++ b/lib/posix-process/process.h @@ -70,6 +70,7 @@ struct posix_process { struct posix_thread { pid_t tid; struct posix_process *process; + struct posix_thread *parent; struct uk_list_head thread_list_entry; struct uk_thread *thread; struct uk_alloc *_a;