You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by li...@apache.org on 2024/10/16 10:24:00 UTC
(nuttx-apps) 01/05: apps: added pid list for ps command.
This is an automated email from the ASF dual-hosted git repository.
ligd pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx-apps.git
commit a655e067ef0ac6b7b7a94ccdb79e2996c6e92e22
Author: zhushiqshi <zh...@xiaomi.com>
AuthorDate: Tue Feb 27 14:18:08 2024 +0800
apps: added pid list for ps command.
Signed-off-by: zhushiqshi <zh...@xiaomi.com>
---
nshlib/nsh_command.c | 3 ++-
nshlib/nsh_proccmds.c | 17 ++++++++++++++---
2 files changed, 16 insertions(+), 4 deletions(-)
diff --git a/nshlib/nsh_command.c b/nshlib/nsh_command.c
index 0e3eb593b..22156b941 100644
--- a/nshlib/nsh_command.c
+++ b/nshlib/nsh_command.c
@@ -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
diff --git a/nshlib/nsh_proccmds.c b/nshlib/nsh_proccmds.c
index ab02f38f5..cfcb1190c 100644
--- a/nshlib/nsh_proccmds.c
+++ b/nshlib/nsh_proccmds.c
@@ -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);
}