public static bool TerminateProcess( PythonSubprocessHandle handle, object uExitCode) { // Alternative Managed API: System.Diagnostics.Process.Kill() IntPtr hProcessIntPtr = new IntPtr(Converter.ConvertToInt32(handle)); uint uExitCodeUint = Converter.ConvertToUInt32(uExitCode); bool result = TerminateProcessPI( hProcessIntPtr, uExitCodeUint); return(result); }
public static int GetExitCodeProcess(PythonSubprocessHandle hProcess) { if (hProcess._isProcess && hProcess._closed) { // deal with finalization & resurrection oddness... see PythonSubprocessHandle finalizer return(hProcess._exitCode); } IntPtr hProcessIntPtr = new IntPtr(Converter.ConvertToInt32(hProcess)); int exitCode = int.MinValue; GetExitCodeProcessPI(hProcessIntPtr, out exitCode); return(exitCode); }
/// <summary> /// Duplicates a subprocess handle which was created for piping. /// /// This is only called when we're duplicating the handle to make it inheritable to the child process. In CPython /// the parent handle is always reliably garbage collected. Because we know this handle is not going to be /// used we close the handle being duplicated. /// </summary> public static PythonSubprocessHandle DuplicateHandle(CodeContext context, BigInteger sourceProcess, PythonSubprocessHandle handle, BigInteger targetProcess, int desiredAccess, bool inherit_handle, object DUPLICATE_SAME_ACCESS) { if (handle._duplicated) { // more ref counting issues - when stderr is set to subprocess.STDOUT we can't close the target handle so we need // to track this situation. return(DuplicateHandle(context, sourceProcess, (BigInteger)handle, targetProcess, desiredAccess, inherit_handle, DUPLICATE_SAME_ACCESS)); } var res = DuplicateHandle(context, sourceProcess, (BigInteger)handle, targetProcess, desiredAccess, inherit_handle, DUPLICATE_SAME_ACCESS); res._duplicated = true; handle.Close(); return(res); }
public static int WaitForSingleObject(PythonSubprocessHandle handle, int dwMilliseconds) { return(WaitForSingleObjectPI(handle, dwMilliseconds)); }
public static void CloseHandle(PythonSubprocessHandle handle) { handle.Close(); }
public static int WaitForSingleObject(PythonSubprocessHandle handle, int dwMilliseconds) { return WaitForSingleObjectPI(handle, dwMilliseconds); }
public static bool TerminateProcess( PythonSubprocessHandle handle, object uExitCode) { // Alternative Managed API: System.Diagnostics.Process.Kill() IntPtr hProcessIntPtr = new IntPtr(Converter.ConvertToInt32(handle)); uint uExitCodeUint = Converter.ConvertToUInt32(uExitCode); bool result = TerminateProcessPI( hProcessIntPtr, uExitCodeUint); return result; }
public static int GetExitCodeProcess(PythonSubprocessHandle hProcess) { if (hProcess._isProcess && hProcess._closed) { // deal with finalization & resurrection oddness... see PythonSubprocessHandle finalizer return hProcess._exitCode; } IntPtr hProcessIntPtr = new IntPtr(Converter.ConvertToInt32(hProcess)); int exitCode = int.MinValue; GetExitCodeProcessPI(hProcessIntPtr, out exitCode); return exitCode; }
/// <summary> /// Duplicates a subprocess handle which was created for piping. /// /// This is only called when we're duplicating the handle to make it inheritable to the child process. In CPython /// the parent handle is always reliably garbage collected. Because we know this handle is not going to be /// used we close the handle being duplicated. /// </summary> public static PythonSubprocessHandle DuplicateHandle(CodeContext context, BigInteger sourceProcess, PythonSubprocessHandle handle, BigInteger targetProcess, int desiredAccess, bool inherit_handle, object DUPLICATE_SAME_ACCESS) { if (handle._duplicated) { // more ref counting issues - when stderr is set to subprocess.STDOUT we can't close the target handle so we need // to track this situation. return DuplicateHandle(context, sourceProcess, (BigInteger)handle, targetProcess, desiredAccess, inherit_handle, DUPLICATE_SAME_ACCESS); } var res = DuplicateHandle(context, sourceProcess, (BigInteger)handle, targetProcess, desiredAccess, inherit_handle, DUPLICATE_SAME_ACCESS); res._duplicated = true; handle.Close(); return res; }