mirror of
https://github.com/apache/nuttx-apps.git
synced 2025-10-17 07:12:06 +08:00
apps/nshlib: Add the pidof command and API nsh_getpid
Add the API "nsh_getpid" in "nsh_fsutils. c" and the nsh command pidof. Temporarily support two parameters, - s, and process name Signed-off-by: wangmingrong <wangmingrong@xiaomi.com>
This commit is contained in:
30
nshlib/nsh.h
30
nshlib/nsh.h
@@ -576,9 +576,8 @@
|
||||
*/
|
||||
|
||||
#if defined(CONFIG_NSH_DISABLE_LS) && defined(CONFIG_NSH_DISABLE_PS) && \
|
||||
defined(CONFIG_NSH_DISABLE_FDINFO) && \
|
||||
defined(CONFIG_NSH_DISABLE_RPTUN) && \
|
||||
defined(CONFIG_NSH_DISABLE_PMCONFIG)
|
||||
defined(CONFIG_NSH_DISABLE_RPTUN) && defined(CONFIG_NSH_DISABLE_PMCONFIG) && \
|
||||
defined(CONFIG_NSH_DISABLE_FDINFO) && defined(CONFIG_NSH_DISABLE_PIDOF)
|
||||
# undef NSH_HAVE_FOREACH_DIRENTRY
|
||||
#endif
|
||||
|
||||
@@ -956,6 +955,9 @@ void nsh_usbtrace(void);
|
||||
#ifndef CONFIG_NSH_DISABLE_PS
|
||||
int cmd_ps(FAR struct nsh_vtbl_s *vtbl, int argc, FAR char **argv);
|
||||
#endif
|
||||
#if defined(CONFIG_FS_PROCFS) && !defined(CONFIG_NSH_DISABLE_PIDOF)
|
||||
int cmd_pidof(FAR struct nsh_vtbl_s *vtbl, int argc, FAR char **argv);
|
||||
#endif
|
||||
#if defined(CONFIG_FS_PROCFS) && !defined(CONFIG_NSH_DISABLE_FDINFO)
|
||||
int cmd_fdinfo(FAR struct nsh_vtbl_s *vtbl, int argc, FAR char **argv);
|
||||
#endif
|
||||
@@ -1381,6 +1383,28 @@ int nsh_foreach_direntry(FAR struct nsh_vtbl_s *vtbl, FAR const char *cmd,
|
||||
nsh_direntry_handler_t handler, void *pvarg);
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Name: nsh_getpid
|
||||
*
|
||||
* Description:
|
||||
* Obtain pid through process name
|
||||
*
|
||||
* Input Parameters:
|
||||
* vtbl - NSH session data
|
||||
* name - the name of the process
|
||||
* pids - allocated array for storing pid
|
||||
* count - the maximum number of pids obtained
|
||||
*
|
||||
* Returned value:
|
||||
* the actual number of pids obtained
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#if defined(CONFIG_FS_PROCFS) && !defined(CONFIG_NSH_DISABLE_PIDOF)
|
||||
ssize_t nsh_getpid(FAR struct nsh_vtbl_s *vtbl, FAR const char *name,
|
||||
FAR pid_t *pids, size_t count);
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Name: nsh_trimdir
|
||||
*
|
||||
|
Reference in New Issue
Block a user