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 <wangjianyu3@xiaomi.com>
This commit is contained in:
wangjianyu3
2024-11-13 20:41:29 +08:00
committed by Xiang Xiao
parent 9f859e914d
commit 687c1cacd9
4 changed files with 7 additions and 3 deletions

View File

@@ -715,6 +715,7 @@ config NSH_DISABLE_WAIT
bool "Disable wait" bool "Disable wait"
default DEFAULT_SMALL default DEFAULT_SMALL
depends on SCHED_WAITPID depends on SCHED_WAITPID
depends on FS_PROCFS && !FS_PROCFS_EXCLUDE_PROCESS
config NSH_DISABLE_WATCH config NSH_DISABLE_WATCH
bool "Disable watch" bool "Disable watch"

View File

@@ -1238,7 +1238,8 @@ int cmd_watch(FAR struct nsh_vtbl_s *vtbl, int argc, FAR char **argv);
#endif #endif
#if !defined(CONFIG_NSH_DISABLE_WAIT) && defined(CONFIG_SCHED_WAITPID) && \ #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); int cmd_wait(FAR struct nsh_vtbl_s *vtbl, int argc, FAR char **argv);
#endif #endif

View File

@@ -679,7 +679,8 @@ static const struct cmdmap_s g_cmdmap[] =
CMD_MAP("xd", cmd_xd, 3, 3, "<hex-address> <byte-count>"), CMD_MAP("xd", cmd_xd, 3, 3, "<hex-address> <byte-count>"),
#endif #endif
#if !defined(CONFIG_NSH_DISABLE_WAIT) && defined(CONFIG_SCHED_WAITPID) && \ #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, CMD_MAP("wait", cmd_wait, 1, CONFIG_NSH_MAXARGUMENTS,
"pid1 [pid2 [pid3] ...]"), "pid1 [pid2 [pid3] ...]"),
#endif #endif

View File

@@ -35,7 +35,8 @@
#include "nsh_console.h" #include "nsh_console.h"
#if !defined(CONFIG_NSH_DISABLE_WAIT) && defined(CONFIG_SCHED_WAITPID) && \ #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:"; static const char g_groupid[] = "Group:";