From 36700ddc0251f40fffe04bb5185fe9e88e3535c5 Mon Sep 17 00:00:00 2001 From: wangjianyu3 Date: Wed, 13 Nov 2024 20:41:29 +0800 Subject: [PATCH] nshlib/cmd_wait: Wait failed if "PROCFS/PROCES" not enabled Env sim:nsh - CONFIG_FS_PROCFS_EXCLUDE_PROCES=y Error nsh> sleep 5 & sh [4:100] nsh> wait 4 nsh: wait: wait failed: 2 cmd_wait(): snprintf(path, sizeof(path), "/proc/%d/status", tid); Signed-off-by: wangjianyu3 --- nshlib/Kconfig | 1 + nshlib/nsh.h | 3 ++- nshlib/nsh_command.c | 3 ++- nshlib/nsh_wait.c | 3 ++- 4 files changed, 7 insertions(+), 3 deletions(-) diff --git a/nshlib/Kconfig b/nshlib/Kconfig index be6ac1b55bf..388099ef0a7 100644 --- a/nshlib/Kconfig +++ b/nshlib/Kconfig @@ -715,6 +715,7 @@ config NSH_DISABLE_WAIT bool "Disable wait" default DEFAULT_SMALL depends on SCHED_WAITPID + depends on FS_PROCFS && !FS_PROCFS_EXCLUDE_PROCESS config NSH_DISABLE_WATCH bool "Disable watch" diff --git a/nshlib/nsh.h b/nshlib/nsh.h index 20d8f82fae9..75c84f856ee 100644 --- a/nshlib/nsh.h +++ b/nshlib/nsh.h @@ -1238,7 +1238,8 @@ int cmd_watch(FAR struct nsh_vtbl_s *vtbl, int argc, FAR char **argv); #endif #if !defined(CONFIG_NSH_DISABLE_WAIT) && defined(CONFIG_SCHED_WAITPID) && \ - !defined(CONFIG_DISABLE_PTHREAD) + !defined(CONFIG_DISABLE_PTHREAD) && defined(CONFIG_FS_PROCFS) && \ + !defined(CONFIG_FS_PROCFS_EXCLUDE_PROCESS) int cmd_wait(FAR struct nsh_vtbl_s *vtbl, int argc, FAR char **argv); #endif diff --git a/nshlib/nsh_command.c b/nshlib/nsh_command.c index 9358d0a9ce6..c31a89b86e8 100644 --- a/nshlib/nsh_command.c +++ b/nshlib/nsh_command.c @@ -679,7 +679,8 @@ static const struct cmdmap_s g_cmdmap[] = CMD_MAP("xd", cmd_xd, 3, 3, " "), #endif #if !defined(CONFIG_NSH_DISABLE_WAIT) && defined(CONFIG_SCHED_WAITPID) && \ - !defined(CONFIG_DISABLE_PTHREAD) + !defined(CONFIG_DISABLE_PTHREAD) && defined(CONFIG_FS_PROCFS) && \ + !defined(CONFIG_FS_PROCFS_EXCLUDE_PROCESS) CMD_MAP("wait", cmd_wait, 1, CONFIG_NSH_MAXARGUMENTS, "pid1 [pid2 [pid3] ...]"), #endif diff --git a/nshlib/nsh_wait.c b/nshlib/nsh_wait.c index c025799ad26..08106736b23 100644 --- a/nshlib/nsh_wait.c +++ b/nshlib/nsh_wait.c @@ -35,7 +35,8 @@ #include "nsh_console.h" #if !defined(CONFIG_NSH_DISABLE_WAIT) && defined(CONFIG_SCHED_WAITPID) && \ - !defined(CONFIG_DISABLE_PTHREAD) + !defined(CONFIG_DISABLE_PTHREAD) && defined(CONFIG_FS_PROCFS) && \ + !defined(CONFIG_FS_PROCFS_EXCLUDE_PROCESS) static const char g_groupid[] = "Group:";