mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-06-27 14:24:40 +00:00
Add a Kill() function to the Program class.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@81246 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@ -103,6 +103,17 @@ namespace sys {
|
||||
///< program.
|
||||
);
|
||||
|
||||
/// This function terminates the program.
|
||||
/// @returns true if an error occured.
|
||||
/// @see Execute
|
||||
/// @brief Terminates the program.
|
||||
bool Kill
|
||||
( std::string* ErrMsg = 0 ///< If non-zero, provides a pointer to a string
|
||||
///< instance in which error messages will be returned. If the string
|
||||
///< is non-empty upon return an error occurred while invoking the
|
||||
///< program.
|
||||
);
|
||||
|
||||
/// This static constructor (factory) will attempt to locate a program in
|
||||
/// the operating system's file system using some pre-determined set of
|
||||
/// locations to search (e.g. the PATH on Unix).
|
||||
|
@ -283,6 +283,16 @@ Program::Wait(unsigned secondsToWait,
|
||||
|
||||
}
|
||||
|
||||
bool
|
||||
Program::Kill(std::string* ErrMsg) {
|
||||
if (Pid_ == 0) {
|
||||
MakeErrMsg(ErrMsg, "Process not started!");
|
||||
return true;
|
||||
}
|
||||
|
||||
return (kill(Pid_, SIGKILL) == 0);
|
||||
}
|
||||
|
||||
bool Program::ChangeStdinToBinary(){
|
||||
// Do nothing, as Unix doesn't differentiate between text and binary.
|
||||
return false;
|
||||
|
@ -335,6 +335,17 @@ Program::Wait(unsigned secondsToWait,
|
||||
return status;
|
||||
}
|
||||
|
||||
bool
|
||||
Program::Kill(std::string* ErrMsg) {
|
||||
if (Data == 0) {
|
||||
MakeErrMsg(ErrMsg, "Process not started!");
|
||||
return true;
|
||||
}
|
||||
|
||||
HANDLE hProcess = reinterpret_cast<HANDLE>(Data);
|
||||
return TerminateProcess(hProcess, 1);
|
||||
}
|
||||
|
||||
bool Program::ChangeStdinToBinary(){
|
||||
int result = _setmode( _fileno(stdin), _O_BINARY );
|
||||
return result == -1;
|
||||
|
Reference in New Issue
Block a user