mirror of
https://github.com/reactos/reactos.git
synced 2024-12-28 10:04:49 +00:00
[KILL] ExecuteKill(): Return '1' on failures
and add a related 'CloseHandle()' call. Also, enforce PID 'unsigned' type.
This commit is contained in:
parent
5a30c71e70
commit
3e3594e3aa
1 changed files with 8 additions and 7 deletions
|
@ -35,25 +35,26 @@
|
|||
#include <stdlib.h>
|
||||
|
||||
int
|
||||
ExecuteKill(char *lpPid)
|
||||
ExecuteKill(const char *lpPid)
|
||||
{
|
||||
HANDLE hProcess;
|
||||
DWORD dwProcessId;
|
||||
|
||||
dwProcessId = (DWORD)atol(lpPid);
|
||||
fprintf(stderr, "Killing PID %ld...\n", dwProcessId);
|
||||
dwProcessId = strtoul(lpPid, NULL, 10);
|
||||
fprintf(stderr, "Killing the process with PID %lu...\n", dwProcessId);
|
||||
|
||||
hProcess = OpenProcess(PROCESS_TERMINATE, FALSE, dwProcessId);
|
||||
if (hProcess == NULL)
|
||||
{
|
||||
fprintf(stderr, "Could not open the process with PID = %ld\n", dwProcessId);
|
||||
return 0;
|
||||
fprintf(stderr, "Could not open the process with PID %lu\n", dwProcessId);
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (!TerminateProcess(hProcess, 0))
|
||||
{
|
||||
fprintf(stderr, "Could not terminate the process with PID = %ld\n", dwProcessId);
|
||||
return 0;
|
||||
fprintf(stderr, "Could not terminate the process with PID %lu\n", dwProcessId);
|
||||
CloseHandle(hProcess);
|
||||
return 1;
|
||||
}
|
||||
|
||||
CloseHandle(hProcess);
|
||||
|
|
Loading…
Reference in a new issue