1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 20:27:45 +00:00

pkill: Print errors when killing a process to stderr

This commit is contained in:
Tim Ledbetter 2023-06-03 21:29:26 +01:00 committed by Andreas Kling
parent e252b6e258
commit 6753cf8b20

View file

@ -1,5 +1,6 @@
/* /*
* Copyright (c) 2022, Maxwell Trussell <maxtrussell@gmail.com> * Copyright (c) 2022, Maxwell Trussell <maxtrussell@gmail.com>
* Copyright (c) 2023, Tim Ledbetter <timledbetter@gmail.com>
* *
* SPDX-License-Identifier: BSD-2-Clause * SPDX-License-Identifier: BSD-2-Clause
*/ */
@ -59,10 +60,11 @@ ErrorOr<int> serenity_main(Main::Arguments args)
} }
for (auto& process : matched_processes) { for (auto& process : matched_processes) {
if (echo) { auto result = Core::System::kill(process.pid, signal);
if (result.is_error())
warnln("Killing pid {} failed. {}", process.pid, result.release_error());
else if (echo)
outln("{} killed (pid {})", process.name, process.pid); outln("{} killed (pid {})", process.name, process.pid);
}
kill(process.pid, signal);
} }
return 0; return 0;
} }