From 8add26934ae8293414e13e648bb599ad3acfee17 Mon Sep 17 00:00:00 2001 From: Mikhail Glushenkov Date: Wed, 9 Sep 2009 09:51:47 +0000 Subject: [PATCH] Check that the 'kill' call succeeded. Thanks to Duncan Sands for spotting this. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@81328 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/System/Unix/Program.inc | 8 +++++++- lib/System/Win32/Program.inc | 7 ++++++- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/lib/System/Unix/Program.inc b/lib/System/Unix/Program.inc index 1ffd71af10d..56dea250a77 100644 --- a/lib/System/Unix/Program.inc +++ b/lib/System/Unix/Program.inc @@ -298,7 +298,13 @@ Program::Kill(std::string* ErrMsg) { uint64_t pid64 = reinterpret_cast(Data_); pid_t pid = static_cast(pid64); - return (kill(pid, SIGKILL) == 0); + + if (kill(pid, SIGKILL) != 0) { + MakeErrMsg(ErrMsg, "The process couldn't be killed!"); + return true; + } + + return false; } bool Program::ChangeStdinToBinary(){ diff --git a/lib/System/Win32/Program.inc b/lib/System/Win32/Program.inc index 87f9e64e4c5..af6cce6de1a 100644 --- a/lib/System/Win32/Program.inc +++ b/lib/System/Win32/Program.inc @@ -347,7 +347,12 @@ Program::Kill(std::string* ErrMsg) { } HANDLE hProcess = reinterpret_cast(Data_); - return TerminateProcess(hProcess, 1); + if (TerminateProcess(hProcess, 1) == 0) { + MakeErrMsg(ErrMsg, "The process couldn't be killed!"); + return true; + } + + return false; } bool Program::ChangeStdinToBinary(){ -- 2.11.0