Skip to content

Commit

Permalink
nshlib/cmd_wait: Wait failed if "PROCFS/PROCES" not enabled
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
JianyuWang0623 committed Nov 13, 2024
1 parent 0c467dc commit 36700dd
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 3 deletions.
1 change: 1 addition & 0 deletions nshlib/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
3 changes: 2 additions & 1 deletion nshlib/nsh.h
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
3 changes: 2 additions & 1 deletion nshlib/nsh_command.c
Original file line number Diff line number Diff line change
Expand Up @@ -679,7 +679,8 @@ static const struct cmdmap_s g_cmdmap[] =
CMD_MAP("xd", cmd_xd, 3, 3, "<hex-address> <byte-count>"),
#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
Expand Down
3 changes: 2 additions & 1 deletion nshlib/nsh_wait.c
Original file line number Diff line number Diff line change
Expand Up @@ -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:";

Expand Down

0 comments on commit 36700dd

Please sign in to comment.