mirror of
https://github.com/reactos/reactos.git
synced 2024-12-31 19:42:51 +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>
|
#include <stdlib.h>
|
||||||
|
|
||||||
int
|
int
|
||||||
ExecuteKill(char *lpPid)
|
ExecuteKill(const char *lpPid)
|
||||||
{
|
{
|
||||||
HANDLE hProcess;
|
HANDLE hProcess;
|
||||||
DWORD dwProcessId;
|
DWORD dwProcessId;
|
||||||
|
|
||||||
dwProcessId = (DWORD)atol(lpPid);
|
dwProcessId = strtoul(lpPid, NULL, 10);
|
||||||
fprintf(stderr, "Killing PID %ld...\n", dwProcessId);
|
fprintf(stderr, "Killing the process with PID %lu...\n", dwProcessId);
|
||||||
|
|
||||||
hProcess = OpenProcess(PROCESS_TERMINATE, FALSE, dwProcessId);
|
hProcess = OpenProcess(PROCESS_TERMINATE, FALSE, dwProcessId);
|
||||||
if (hProcess == NULL)
|
if (hProcess == NULL)
|
||||||
{
|
{
|
||||||
fprintf(stderr, "Could not open the process with PID = %ld\n", dwProcessId);
|
fprintf(stderr, "Could not open the process with PID %lu\n", dwProcessId);
|
||||||
return 0;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!TerminateProcess(hProcess, 0))
|
if (!TerminateProcess(hProcess, 0))
|
||||||
{
|
{
|
||||||
fprintf(stderr, "Could not terminate the process with PID = %ld\n", dwProcessId);
|
fprintf(stderr, "Could not terminate the process with PID %lu\n", dwProcessId);
|
||||||
return 0;
|
CloseHandle(hProcess);
|
||||||
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
CloseHandle(hProcess);
|
CloseHandle(hProcess);
|
||||||
|
|
Loading…
Reference in a new issue