nsh kill cmd can be executed with no signal option.
SIGTERM is the default signal, as in unix kill command. nsh> kill [-<signal>] <pid>
This commit is contained in:
parent
61ddfeba17
commit
42f4565129
@ -261,7 +261,7 @@ static const struct cmdmap_s g_cmdmap[] =
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef CONFIG_NSH_DISABLE_KILL
|
#ifndef CONFIG_NSH_DISABLE_KILL
|
||||||
{ "kill", cmd_kill, 3, 3, "-<signal> <pid>" },
|
{ "kill", cmd_kill, 2, 3, "[-<signal>] <pid>" },
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef CONFIG_DISABLE_MOUNTPOINT
|
#ifndef CONFIG_DISABLE_MOUNTPOINT
|
||||||
|
@ -48,6 +48,7 @@
|
|||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
#include <dirent.h>
|
#include <dirent.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
|
#include <signal.h>
|
||||||
|
|
||||||
#include "nsh.h"
|
#include "nsh.h"
|
||||||
#include "nsh_console.h"
|
#include "nsh_console.h"
|
||||||
@ -618,23 +619,54 @@ int cmd_kill(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv)
|
|||||||
long signal;
|
long signal;
|
||||||
long pid;
|
long pid;
|
||||||
|
|
||||||
/* Check incoming parameters. The first parameter should be "-<signal>" */
|
/* kill will send SIGTERM to the task in case no signal is selected by
|
||||||
|
* -<signal> option
|
||||||
|
*/
|
||||||
|
|
||||||
ptr = argv[1];
|
if (argc == 3) /* kill -<signal> <pid> */
|
||||||
if (*ptr != '-' || ptr[1] < '0' || ptr[1] > '9')
|
|
||||||
{
|
{
|
||||||
goto invalid_arg;
|
/* 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], &endptr, 0);
|
||||||
|
|
||||||
|
/* The second parameter should be <pid> */
|
||||||
|
|
||||||
|
ptr = argv[2];
|
||||||
|
|
||||||
|
if (*ptr < '0' || *ptr > '9')
|
||||||
|
{
|
||||||
|
goto invalid_arg;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
else if (argc == 2) /* kill <pid> */
|
||||||
/* Extract the signal number */
|
|
||||||
|
|
||||||
signal = strtol(&ptr[1], &endptr, 0);
|
|
||||||
|
|
||||||
/* The second parameter should be <pid> */
|
|
||||||
|
|
||||||
ptr = argv[2];
|
|
||||||
if (*ptr < '0' || *ptr > '9')
|
|
||||||
{
|
{
|
||||||
|
/* uses default signal number as SIGTERM */
|
||||||
|
|
||||||
|
signal = (long) SIGTERM; /* SIGTERM is always defined in signal.h */
|
||||||
|
|
||||||
|
/* The first parameter should be <pid> */
|
||||||
|
|
||||||
|
ptr = argv[1];
|
||||||
|
|
||||||
|
if (*ptr < '0' || *ptr > '9')
|
||||||
|
{
|
||||||
|
goto invalid_arg;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
/* invalid number of arguments */
|
||||||
|
|
||||||
goto invalid_arg;
|
goto invalid_arg;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user