apps: added pid list for ps command.

Signed-off-by: zhushiqshi <zhushiqshi@xiaomi.com>
This commit is contained in:
zhushiqshi
2024-02-27 14:18:08 +08:00
committed by GUIDINGLI
parent c98439f9a1
commit a655e067ef
2 changed files with 16 additions and 4 deletions

View File

@@ -474,7 +474,8 @@ static const struct cmdmap_s g_cmdmap[] =
#endif
#ifndef CONFIG_NSH_DISABLE_PS
CMD_MAP("ps", cmd_ps, 1, 1, NULL),
CMD_MAP("ps", cmd_ps, 1, CONFIG_NSH_MAXARGUMENTS,
"<pid1 pid2 ...>"),
#endif
#ifdef CONFIG_NET_UDP

View File

@@ -620,9 +620,6 @@ int cmd_exec(FAR struct nsh_vtbl_s *vtbl, int argc, FAR char **argv)
#ifndef CONFIG_NSH_DISABLE_PS
int cmd_ps(FAR struct nsh_vtbl_s *vtbl, int argc, FAR char **argv)
{
UNUSED(argc);
UNUSED(argv);
nsh_output(vtbl, "%5s %5s "
#ifdef CONFIG_SMP
"%3s "
@@ -665,6 +662,20 @@ int cmd_ps(FAR struct nsh_vtbl_s *vtbl, int argc, FAR char **argv)
"COMMAND"
);
if (argc > 1)
{
int i;
for (i = 1; i < argc; i++)
{
struct dirent entry;
entry.d_type = DT_DIR;
strcpy(entry.d_name, argv[i]);
ps_callback(vtbl, CONFIG_NSH_PROC_MOUNTPOINT, &entry, NULL);
}
return 0;
}
return nsh_foreach_direntry(vtbl, "ps", CONFIG_NSH_PROC_MOUNTPOINT,
ps_callback, NULL);
}