nsh:support wait command to wait task exit.

usage like:
  nsh> sleep 10 &
  [5:100]
  nsh>set pid1=$!
  nsh>sleep 15 &
  [6:100]
  nsh>set pid2=$!
  nsh>wait $pid1 $pid2

'wait' command will block nsh from running until pid1 and pid2 finish.
This is useful for parallel requirements to perform certain tasks

Signed-off-by: anjiahao <anjiahao@xiaomi.com>
This commit is contained in:
anjiahao
2023-12-27 14:57:30 +08:00
committed by Xiang Xiao
parent 8d1966e9fc
commit c916f163f2
7 changed files with 179 additions and 6 deletions

View File

@@ -666,6 +666,11 @@ static const struct cmdmap_s g_cmdmap[] =
#ifndef CONFIG_NSH_DISABLE_XD
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)
CMD_MAP("wait", cmd_wait, 1, CONFIG_NSH_MAXARGUMENTS,
"pid1 [pid2 [pid3] ...]"),
#endif
CMD_MAP(NULL, NULL, 1, 1, NULL)
};