diff --git a/user/pctl/kill.c b/user/pctl/kill.c new file mode 100644 index 0000000..359b554 --- /dev/null +++ b/user/pctl/kill.c @@ -0,0 +1,28 @@ +#include +#include +#include +#include "kill.h" +#include "macros.h" + +struct { + int32_t pid; +} PCTL_KILL_CONFIG = { + .pid = -1, +}; + +static Arg ARGS[] = { + ARG("-pid", ARG_INT, &PCTL_KILL_CONFIG.pid), + ARG_END(), +}; + +void pctl_kill(void) { + int32_t ret; + if ((ret = parse_args(SUBCMD_ARGS(), SUBCMD_ARGSLEN(), ARGS)) < 0) { + uprintf("pctl kill: Could not parse args: %d\n", ret); + return; + } + + if (PCTL_KILL_CONFIG.pid != -1) { + processctl(PCTL_KILL_CONFIG.pid, PCTL_KILL, 0, 0, 0); + } +} diff --git a/user/pctl/kill.h b/user/pctl/kill.h new file mode 100644 index 0000000..754f71f --- /dev/null +++ b/user/pctl/kill.h @@ -0,0 +1,6 @@ +#ifndef PCTL_KILL_H_ +#define PCTL_KILL_H_ + +void pctl_kill(void); + +#endif // PCTL_KILL_H_ diff --git a/user/pctl/main.c b/user/pctl/main.c index ab7d995..01f0bfa 100644 --- a/user/pctl/main.c +++ b/user/pctl/main.c @@ -2,6 +2,7 @@ #include #include #include "ls.h" +#include "kill.h" void main(void) { if (argslen() == 0) { @@ -12,6 +13,8 @@ void main(void) { if (string_strcmp(cmd, "ls") == 0) { pctl_ls(); + } else if (string_strcmp(cmd, "kill") == 0) { + pctl_kill(); } else { uprintf("pctl: unknown command %s\n", cmd); }