1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 11:47:35 +00:00

Minor tweak to /bin/kill.

This commit is contained in:
Andreas Kling 2018-11-08 02:07:08 +01:00
parent 71a2942a0a
commit 41a751c90c

View file

@ -6,6 +6,10 @@
static unsigned parseUInt(const String& str, bool& ok) static unsigned parseUInt(const String& str, bool& ok)
{ {
if (str.isEmpty()) {
ok = false;
return 0;
}
unsigned value = 0; unsigned value = 0;
for (size_t i = 0; i < str.length(); ++i) { for (size_t i = 0; i < str.length(); ++i) {
if (str[i] < '0' || str[i] > '9') { if (str[i] < '0' || str[i] > '9') {
@ -38,13 +42,13 @@ int main(int argc, char** argv)
print_usage_and_exit(); print_usage_and_exit();
signum = parseUInt(&argv[1][1], ok); signum = parseUInt(&argv[1][1], ok);
if (!ok) { if (!ok) {
printf("%s is not a valid signal number\n", &argv[1][1]); printf("'%s' is not a valid signal number\n", &argv[1][1]);
return 2; return 2;
} }
} }
unsigned pid = parseUInt(argv[pid_argi], ok); unsigned pid = parseUInt(argv[pid_argi], ok);
if (!ok) { if (!ok) {
printf("%s is not a valid PID\n", argv[pid_argi]); printf("'%s' is not a valid PID\n", argv[pid_argi]);
return 3; return 3;
} }