michallenc commented on code in PR #2585:
URL: https://github.com/apache/nuttx-apps/pull/2585#discussion_r1767350323


##########
nshlib/nsh_proccmds.c:
##########
@@ -801,6 +801,107 @@ int cmd_kill(FAR struct nsh_vtbl_s *vtbl, int argc, FAR 
char **argv)
 }
 #endif
 
+/****************************************************************************
+ * Name: cmd_pkill
+ ****************************************************************************/
+
+#if defined(CONFIG_FS_PROCFS) && !defined(CONFIG_NSH_DISABLE_PKILL)
+int cmd_pkill(FAR struct nsh_vtbl_s *vtbl, int argc, FAR char **argv)
+{
+  FAR const char *name;
+  FAR char *ptr;
+  pid_t pids[8];
+  long signal;
+  ssize_t ret;
+  int i;
+
+  /* pkill will send SIGTERM to the task in case no signal is selected by
+   * -<signal> option
+   */
+
+  if (argc == 3)  /* pkill -<signal> <name> */
+    {
+      /* Check incoming parameters.
+       * The first parameter should be "-<signal>"
+       */
+
+      ptr = argv[1];
+      if (*ptr != '-' || ptr[1] < '0' || ptr[1] > '9')
+        {
+          goto invalid_arg;
+        }
+
+      /* Extract the signal number */
+
+      signal = strtol(&ptr[1], NULL, 0);

Review Comment:
   `kill()` does the check itself and returns `EINVAL` if signal is not valid.
   



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to