From 56baf8e2e8d87e0d22f606d0735995f9f2eab226 Mon Sep 17 00:00:00 2001 From: Serge Gautherie Date: Tue, 27 Feb 2024 22:42:54 +0100 Subject: [PATCH] [FORMATTING][KILL] kill.c: reformat it --- .../rosapps/applications/sysutils/kill/kill.c | 71 +++++++++---------- 1 file changed, 35 insertions(+), 36 deletions(-) diff --git a/modules/rosapps/applications/sysutils/kill/kill.c b/modules/rosapps/applications/sysutils/kill/kill.c index bce146ad721..8c32b64c3f5 100644 --- a/modules/rosapps/applications/sysutils/kill/kill.c +++ b/modules/rosapps/applications/sysutils/kill/kill.c @@ -28,51 +28,50 @@ * from the old shell.exe */ -#define WIN32_LEAN_AND_MEAN /* Exclude rarely-used stuff from Windows headers */ +#define WIN32_LEAN_AND_MEAN /* Exclude rarely-used stuff from Windows headers */ #include + #include #include int -ExecuteKill(char * lpPid) +ExecuteKill(char *lpPid) { - HANDLE hProcess; - DWORD dwProcessId; + HANDLE hProcess; + DWORD dwProcessId; - dwProcessId = (DWORD) atol(lpPid); - fprintf( stderr, "Killing PID %ld...\n",dwProcessId); - hProcess = OpenProcess( - PROCESS_TERMINATE, - FALSE, - dwProcessId - ); - if (NULL == hProcess) - { - fprintf( stderr, "Could not open the process with PID = %ld\n", dwProcessId); - return 0; - } - if (FALSE == TerminateProcess( - hProcess, - 0 - ) - ) { - fprintf( stderr, "Could not terminate the process with PID = %ld\n", dwProcessId); - return 0; - } - CloseHandle(hProcess); - return 0; + dwProcessId = (DWORD)atol(lpPid); + fprintf(stderr, "Killing PID %ld...\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; + } + + if (!TerminateProcess(hProcess, 0)) + { + fprintf(stderr, "Could not terminate the process with PID = %ld\n", dwProcessId); + return 0; + } + + CloseHandle(hProcess); + return 0; } -int main(int argc, char *argv[]) +int +main(int argc, char *argv[]) { - char tail; - DBG_UNREFERENCED_LOCAL_VARIABLE(tail); + char tail; + DBG_UNREFERENCED_LOCAL_VARIABLE(tail); - if (argc < 2) - { - fprintf( stderr, "Usage: %s PID (Process ID) \n", argv[0] ); - return 1; - } - tail = ExecuteKill(argv[1]); - return 0; + if (argc < 2) + { + fprintf(stderr, "Usage: %s PID (Process ID) \n", argv[0]); + return 1; + } + + tail = ExecuteKill(argv[1]); + return 0; }