disable job control in console pauser before windows xp (#420)
This commit is contained in:
parent
e67a9992c2
commit
b69f234840
|
@ -24,6 +24,7 @@ using std::string;
|
||||||
#include <processthreadsapi.h>
|
#include <processthreadsapi.h>
|
||||||
#include <conio.h>
|
#include <conio.h>
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
|
#include <versionhelpers.h>
|
||||||
|
|
||||||
#ifndef WINBOOL
|
#ifndef WINBOOL
|
||||||
#define WINBOOL BOOL
|
#define WINBOOL BOOL
|
||||||
|
@ -52,6 +53,7 @@ enum RunProgramFlag {
|
||||||
};
|
};
|
||||||
|
|
||||||
HANDLE hJob;
|
HANDLE hJob;
|
||||||
|
bool enableJobControl = IsWindowsXPOrGreater();
|
||||||
|
|
||||||
bool pauseBeforeExit = false;
|
bool pauseBeforeExit = false;
|
||||||
|
|
||||||
|
@ -154,11 +156,13 @@ DWORD ExecuteCommand(string& command,bool reInp, LONGLONG &peakMemory, LONGLONG
|
||||||
printf("\nError %lu: %s\n",GetLastError(),GetErrorMessage().c_str());
|
printf("\nError %lu: %s\n",GetLastError(),GetErrorMessage().c_str());
|
||||||
PauseExit(EXIT_CREATE_PROCESS_FAILED,reInp);
|
PauseExit(EXIT_CREATE_PROCESS_FAILED,reInp);
|
||||||
}
|
}
|
||||||
|
if (enableJobControl) {
|
||||||
WINBOOL bSuccess = AssignProcessToJobObject( hJob, pi.hProcess );
|
WINBOOL bSuccess = AssignProcessToJobObject( hJob, pi.hProcess );
|
||||||
if ( bSuccess == FALSE ) {
|
if ( bSuccess == FALSE ) {
|
||||||
printf( "AssignProcessToJobObject failed: error %lu\n", GetLastError() );
|
printf( "AssignProcessToJobObject failed: error %lu\n", GetLastError() );
|
||||||
PauseExit(EXIT_ASSGIN_PROCESS_JOB_FAILED,reInp);
|
PauseExit(EXIT_ASSGIN_PROCESS_JOB_FAILED,reInp);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
WaitForSingleObject(pi.hProcess, INFINITE); // Wait for it to finish
|
WaitForSingleObject(pi.hProcess, INFINITE); // Wait for it to finish
|
||||||
|
|
||||||
|
@ -221,6 +225,7 @@ int main(int argc, char** argv) {
|
||||||
// Then build the to-run application command
|
// Then build the to-run application command
|
||||||
string command = GetCommand(argc, argv, reInp, enableVisualTerminalSeq);
|
string command = GetCommand(argc, argv, reInp, enableVisualTerminalSeq);
|
||||||
|
|
||||||
|
if (enableJobControl) {
|
||||||
hJob= CreateJobObject( &sa, NULL );
|
hJob= CreateJobObject( &sa, NULL );
|
||||||
|
|
||||||
if ( hJob == NULL ) {
|
if ( hJob == NULL ) {
|
||||||
|
@ -236,6 +241,7 @@ int main(int argc, char** argv) {
|
||||||
printf( "SetInformationJobObject failed: error %lu\n", GetLastError() );
|
printf( "SetInformationJobObject failed: error %lu\n", GetLastError() );
|
||||||
PauseExit(EXIT_SET_JOB_OBJ_INFO_FAILED,reInp);
|
PauseExit(EXIT_SET_JOB_OBJ_INFO_FAILED,reInp);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
HANDLE hOutput = NULL;
|
HANDLE hOutput = NULL;
|
||||||
if (reInp) {
|
if (reInp) {
|
||||||
|
|
Loading…
Reference in New Issue