/// <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 void CloseHandle(PythonSubprocessHandle handle) { handle.Close(); }
/// <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; }