python: handling stderr stream when using createprocessasuser api in windows -


Debug this problem requires some help. I tried to find online and stack overflow but there was no solution for this. I am quite new to the Windows API. So in my ignorance, please forgive

Actually, I'm trying to run a C ++ application that output the stdout of the dragon using a specific user and stderr is. For this purpose, I am using the binary API LogonUser and CreateProcessAsUser API and implement production and use of pipes to capture error streams. The code is mostly picked up from a demo code in Python Win32 module. However, for some reason when my process is dumping in the error stream, it is hung on WriteFile. By looking at the crash dump, I know that FileHandle2 (stderr) is there. Can anyone help me with this issue

thanks in advance

Here's the code snippet -?

  userToken = win32security.LogonUser (user, domain, password, win32con.LOGON32_LOGON_BATCH, win32con.LOGON32_PROVIDER_DEFAULT) secAttrs = win32security.SECURITY_ATTRIBUTES () secAttrs.bInheritHandle = 1 stdout_r, stdout_w = win32pipe.CreatePipe ( SecondEnters, 0) stderr_r, stderr_w = win32pipe.CreatePipe (secAttrs, 0) startupInfo = Win32process.STARTUPINFO () startupInfo.dwFlags = win32con.STARTF_USESTDHANDLES startupInfo.hStdOutput = stdout_w startupInfo.hstdError = stderr_w ppid = win32api.GetCurrentProcess () TMP = win32api .DuplicateHandle (Peepiaidi, Stdout_r, Peepiaidi, 0, 0, win32con.DUPLICATE_SAME_ACCESS) stdout_r win32file .CloseHandle (stdout_r) = tmp procArgs = (no, # AppName Cmd_line, # Commands No, # ProcessAttributes no, # thread properties 1 , #BinHeat Handles, win32process.CREATE_NEW_CONSOLE, # dwCreationFlags, # newEnvironment None, # currentDirectory startupInfo) procHandles = win32process.CreateProcessAsUser (user token, * procArgs) win32file.CloseHandle (stderr_w) win32file.CloseHandle (stdout_w) win32security.RevertToSelf () #HProcess process complete having, HThread, PID, TID = procHandles stdout_buf = os.fdopen (msvcrt.open_osfhandle (stdout_r, 0), "rb") stdout = stdout_buf.read () wait for stderr_buf = os.fdopen (msvcrt.open_osfhandle to (stderr_r, 0), "rb") stderr = stderr_buf.read () win32event.WaitForSingleObject (hProcess, 3600 * 1000) RC = win32process.GetExitCodeProcess (hProcess)  
< P>

Comments

Popular posts from this blog

Member with no value in F# -

java - Joda Time Interval Not returning what I expect -

c# - Showing a SelectedItem's Property -