From eda7f5f379b6b34e01b620b775595613fcc96e1b Mon Sep 17 00:00:00 2001 From: Gregory Nutt Date: Thu, 1 Aug 2019 08:09:50 -0600 Subject: [PATCH] sched/task/task_exithook.c: nxtask_signalparent() in task_exithook.c may invalidate the group's parent task ID (tg_ppid) too soon. The tg_ppid field is use only to remember the parent tasks ID so that it can send the SIGCHLD signal to it. So it must stay valid until SIGCHLD has been sent. In nxtask_signalparent(), it calls nxtask_sigchild() to send SIGCHLD to the parent, then invalidates tg_ppid. That would be okay, except that the SIGCHLD is only sent when the last member of the group terminates. That is incorrect; tg_ppid can be invalidated too soon and, as a consequence, SIGCHLD would never be sent. Noted by Jeongchan Kim in the Google group: https://groups.google.com/forum/#!topic/nuttx/SXd8fVwVKBk --- COPYING | 2 +- sched/task/task_exithook.c | 4 ---- sched/task/task_terminate.c | 2 +- 3 files changed, 2 insertions(+), 6 deletions(-) diff --git a/COPYING b/COPYING index 79ebbeac36..d0be8ba9c8 100644 --- a/COPYING +++ b/COPYING @@ -49,7 +49,7 @@ files will vary): /**************************************************************************** * directory path/filename * - * Copyright (C) 2007-2018 Gregory Nutt. All rights reserved. + * Copyright (C) 2007-2019 Gregory Nutt. All rights reserved. * Author: Gregory Nutt * * Redistribution and use in source and binary forms, with or without diff --git a/sched/task/task_exithook.c b/sched/task/task_exithook.c index 898c19c3ca..649006780e 100644 --- a/sched/task/task_exithook.c +++ b/sched/task/task_exithook.c @@ -476,10 +476,6 @@ static inline void nxtask_signalparent(FAR struct tcb_s *ctcb, int status) /* Send SIGCHLD to all members of the parent's task group */ nxtask_sigchild(ptcb, ctcb, status); - - /* Forget who our parent was */ - - ctcb->group->tg_ppid = INVALID_PROCESS_ID; sched_unlock(); #endif } diff --git a/sched/task/task_terminate.c b/sched/task/task_terminate.c index e8a137c30c..a8a2373875 100644 --- a/sched/task/task_terminate.c +++ b/sched/task/task_terminate.c @@ -60,7 +60,7 @@ * Name: nxtask_terminate * * Description: - * This function causes a specified task to cease to exist. Its stack and + * This function causes a specified task to cease to exist. Its stack and * TCB will be deallocated. This function is the internal implementation * of the task_delete() function. It includes and additional parameter * to determine if blocking is permitted or not.