mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-22 23:50:19 +00:00
3218f00099
All it can do right now is send SIGKILL which just murders the target task.
37 lines
745 B
C++
37 lines
745 B
C++
#include <LibC/unistd.h>
|
|
#include <LibC/stdio.h>
|
|
#include <LibC/signal.h>
|
|
#include <AK/String.h>
|
|
|
|
static unsigned parseUInt(const String& str, bool& ok)
|
|
{
|
|
unsigned value = 0;
|
|
for (size_t i = 0; i < str.length(); ++i) {
|
|
if (str[i] < '0' || str[i] > '9') {
|
|
ok = false;
|
|
return 0;
|
|
}
|
|
value = value * 10;
|
|
value += str[i] - '0';
|
|
}
|
|
ok = true;
|
|
return value;
|
|
}
|
|
|
|
int main(int argc, char** argv)
|
|
{
|
|
if (argc < 2) {
|
|
printf("usage: kill <PID>\n");
|
|
return 1;
|
|
}
|
|
bool ok;
|
|
unsigned value = parseUInt(argv[1], ok);
|
|
if (!ok) {
|
|
printf("%s is not a valid PID\n", argv[1]);
|
|
return 2;
|
|
}
|
|
|
|
kill((pid_t)value, SIGKILL);
|
|
return 0;
|
|
}
|
|
|