You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by xi...@apache.org on 2022/10/21 10:48:04 UTC

[incubator-nuttx] branch master updated: fs/procfs: check task status before get group info

This is an automated email from the ASF dual-hosted git repository.

xiaoxiang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-nuttx.git


The following commit(s) were added to refs/heads/master by this push:
     new 16b6d365e9 fs/procfs: check task status before get group info
16b6d365e9 is described below

commit 16b6d365e949b28718cb395b6e8981359feb8e0f
Author: zhangyuan21 <zh...@xiaomi.com>
AuthorDate: Tue Oct 18 19:33:34 2022 +0800

    fs/procfs: check task status before get group info
    
    When ps cmd is invoked during the task exit process, the group information of the task may be deleted.
    So need check the task flag before get the task group information.
---
 fs/procfs/fs_procfsproc.c | 8 ++------
 1 file changed, 2 insertions(+), 6 deletions(-)

diff --git a/fs/procfs/fs_procfsproc.c b/fs/procfs/fs_procfsproc.c
index f628753fa2..f5919a2580 100644
--- a/fs/procfs/fs_procfsproc.c
+++ b/fs/procfs/fs_procfsproc.c
@@ -493,7 +493,6 @@ static ssize_t proc_status(FAR struct proc_file_s *procfile,
                            FAR struct tcb_s *tcb, FAR char *buffer,
                            size_t buflen, off_t offset)
 {
-  FAR struct task_group_s *group;
   FAR const char *policy;
   FAR const char *name;
   size_t remaining;
@@ -543,12 +542,9 @@ static ssize_t proc_status(FAR struct proc_file_s *procfile,
       return totalsize;
     }
 
-  group = tcb->group;
-  DEBUGASSERT(group != NULL);
-
   linesize   = procfs_snprintf(procfile->line, STATUS_LINELEN,
-                               "%-12s%d\n",
-                               "Group:", group->tg_pid);
+                               "%-12s%d\n", "Group:",
+                               tcb->group ? tcb->group->tg_pid : -1);
   copysize   = procfs_memcpy(procfile->line, linesize, buffer, remaining,
                              &offset);