nshlib/nsh_proccmds.c: update ps_callback when get Group

Cause of "Group:" always have in file "status"

Signed-off-by: ligd <liguiding1@xiaomi.com>
This commit is contained in:
ligd 2021-11-09 16:25:41 +08:00 committed by Gustavo Henrique Nihei
parent 850c036c58
commit a4dd508c9c

View File

@ -45,18 +45,6 @@
# define CONFIG_NSH_PROC_MOUNTPOINT "/proc" # define CONFIG_NSH_PROC_MOUNTPOINT "/proc"
#endif #endif
/* See include/nuttx/sched.h: */
#undef HAVE_GROUPID
#if defined(CONFIG_SCHED_HAVE_PARENT) && defined(CONFIG_SCHED_CHILD_STATUS)
# define HAVE_GROUPID 1
#endif
#ifdef CONFIG_DISABLE_PTHREAD
# undef HAVE_GROUPID
#endif
/**************************************************************************** /****************************************************************************
* Private Types * Private Types
****************************************************************************/ ****************************************************************************/
@ -72,13 +60,7 @@ typedef int (*exec_t)(void);
struct nsh_taskstatus_s struct nsh_taskstatus_s
{ {
FAR const char *td_type; /* Thread type */ FAR const char *td_type; /* Thread type */
#ifdef CONFIG_SCHED_HAVE_PARENT
#ifdef HAVE_GROUPID
FAR const char *td_groupid; /* Group ID */ FAR const char *td_groupid; /* Group ID */
#else
FAR const char *td_ppid; /* Parent thread ID */
#endif
#endif
#ifdef CONFIG_SMP #ifdef CONFIG_SMP
FAR const char *td_cpu; /* CPU */ FAR const char *td_cpu; /* CPU */
#endif #endif
@ -98,14 +80,7 @@ static const char g_name[] = "Name:";
#endif #endif
static const char g_type[] = "Type:"; static const char g_type[] = "Type:";
#ifdef CONFIG_SCHED_HAVE_PARENT
#ifdef HAVE_GROUPID
static const char g_groupid[] = "Group:"; static const char g_groupid[] = "Group:";
#else
static const char g_ppid[] = "PPID:";
#endif
#endif /* CONFIG_SCHED_HAVE_PARENT */
#ifdef CONFIG_SMP #ifdef CONFIG_SMP
static const char g_cpu[] = "CPU:"; static const char g_cpu[] = "CPU:";
@ -175,24 +150,12 @@ static void nsh_parse_statusline(FAR char *line,
status->td_type = nsh_trimspaces(&line[12]); status->td_type = nsh_trimspaces(&line[12]);
} }
#ifdef CONFIG_SCHED_HAVE_PARENT
#ifdef HAVE_GROUPID
else if (strncmp(line, g_groupid, strlen(g_groupid)) == 0) else if (strncmp(line, g_groupid, strlen(g_groupid)) == 0)
{ {
/* Save the Group ID */ /* Save the Group ID */
status->td_groupid = nsh_trimspaces(&line[12]); status->td_groupid = nsh_trimspaces(&line[12]);
} }
#else
else if (strncmp(line, g_ppid, strlen(g_ppid)) == 0)
{
/* Save the parent thread id */
status->td_ppid = nsh_trimspaces(&line[12]);
}
#endif
#endif
#ifdef CONFIG_SMP #ifdef CONFIG_SMP
else if (strncmp(line, g_cpu, strlen(g_cpu)) == 0) else if (strncmp(line, g_cpu, strlen(g_cpu)) == 0)
@ -299,13 +262,7 @@ static int ps_callback(FAR struct nsh_vtbl_s *vtbl, FAR const char *dirpath,
/* Set all pointers to the empty string. */ /* Set all pointers to the empty string. */
status.td_type = ""; status.td_type = "";
#ifdef CONFIG_SCHED_HAVE_PARENT
#ifdef HAVE_GROUPID
status.td_groupid = ""; status.td_groupid = "";
#else
status.td_ppid = "";
#endif
#endif
#ifdef CONFIG_SMP #ifdef CONFIG_SMP
status.td_cpu = ""; status.td_cpu = "";
#endif #endif
@ -365,14 +322,7 @@ static int ps_callback(FAR struct nsh_vtbl_s *vtbl, FAR const char *dirpath,
/* Finally, print the status information */ /* Finally, print the status information */
nsh_output(vtbl, "%5s ", entryp->d_name); nsh_output(vtbl, "%5s ", entryp->d_name);
#ifdef CONFIG_SCHED_HAVE_PARENT
#ifdef HAVE_GROUPID
nsh_output(vtbl, "%5s ", status.td_groupid); nsh_output(vtbl, "%5s ", status.td_groupid);
#else
nsh_output(vtbl, "%5s ", status.td_ppid);
#endif
#endif
#ifdef CONFIG_SMP #ifdef CONFIG_SMP
nsh_output(vtbl, "%3s ", status.td_cpu); nsh_output(vtbl, "%3s ", status.td_cpu);
@ -556,14 +506,7 @@ int cmd_exec(FAR struct nsh_vtbl_s *vtbl, int argc, FAR char **argv)
int cmd_ps(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv) int cmd_ps(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv)
{ {
nsh_output(vtbl, "%5s ", "PID"); nsh_output(vtbl, "%5s ", "PID");
#ifdef CONFIG_SCHED_HAVE_PARENT
#ifdef HAVE_GROUPID
nsh_output(vtbl, "%5s ", "GROUP"); nsh_output(vtbl, "%5s ", "GROUP");
#else
nsh_output(vtbl, "%5s ", "PPID");
#endif
#endif
#ifdef CONFIG_SMP #ifdef CONFIG_SMP
nsh_output(vtbl, "%3s ", "CPU"); nsh_output(vtbl, "%3s ", "CPU");