![]() |
![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
| Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks. |
| |||||||
![]() |
| |
| | #1 (permalink) |
| | Deadlock when logging to stdout and stderr Hi all, I created for my company a build and tests system which is mainly based on PS scripts. As we use it to build different langages (Java, C#, C++), my system uses external program to effectively run the builds and the tests. To run external software, I use a ProcessStartInfo object, like this: $si = New-Object -TypeName System.Diagnostics.ProcessStartInfo $si.FileName = "cvs.exe" $si.RedirectStandardOutput = $true $si.RedirectStandardError = $true $si.UseShellExecute = $false $si.RedirectStandardOutput = $true $si.RedirectStandardError = $true $p = [diagnostics.process]::Start($si) $output = $p.StandardOutput.ReadToEnd() $errors = $p.StandardError.ReadToEnd() $p.WaitForExit() Log-Message $log Info $output if($errors.Length -gt 0) { Log-Message $log ERROR $errors } I'm facing a pretty blocking issue with thr stderr and stdout redirection, in some case, when the amount of traces is pretty big, my PS script is blocked completely blocked. I checked the external program is well terminated, so the problem doesn't seem to come from external programs (which are pretty different) but from Powershell which doesn't handle redirection correctly. Or the error is on my side. I tried to remove the redirection and everything works well, if I ask the developer to stop their output traces during the test, same thing, everything works well. So, I'm here to find a little help. Thanks in advance. |
My System Specs![]() |
| | #2 (permalink) |
| | Re: Deadlock when logging to stdout and stderr I'm fairly certain that your problem here is that either your output or your error buffer fills up while you're waiting for the other buffer, producing a deadlock. See here for a brief description of the problem: http://blogs.msdn.com/lucian/archive...darderror.aspx The standard solution is to handle reading output and reading error from distinct threads - something that I'm not well-acquainted with, but that _can_ be done. Since this has been sitting here a week with no responses, ping back if you're still trying to resolve this and I can do some more looking. This problem definitely _can_ be solved. "Romuald" <Romuald@xxxxxx> wrote in message news:A7E99F3E-BC07-4152-B66E-E5ED7F3803B5@xxxxxx Quote: > Hi all, > I created for my company a build and tests system which is mainly based on > PS scripts. As we use it to build different langages (Java, C#, C++), my > system uses external program to effectively run the builds and the tests. > > To run external software, I use a ProcessStartInfo object, like this: > > $si = New-Object -TypeName System.Diagnostics.ProcessStartInfo > $si.FileName = "cvs.exe" > $si.RedirectStandardOutput = $true > $si.RedirectStandardError = $true > $si.UseShellExecute = $false > $si.RedirectStandardOutput = $true > $si.RedirectStandardError = $true > > $p = [diagnostics.process]::Start($si) > > $output = $p.StandardOutput.ReadToEnd() > $errors = $p.StandardError.ReadToEnd() > > $p.WaitForExit() > > Log-Message $log Info $output > > if($errors.Length -gt 0) > { > Log-Message $log ERROR $errors > } > > I'm facing a pretty blocking issue with thr stderr and stdout redirection, > in some case, when the amount of traces is pretty big, my PS script is > blocked completely blocked. I checked the external program is well > terminated, so the problem doesn't seem to come from external programs > (which > are pretty different) but from Powershell which doesn't handle redirection > correctly. > > Or the error is on my side. > > I tried to remove the redirection and everything works well, if I ask the > developer to stop their output traces during the test, same thing, > everything > works well. > > So, I'm here to find a little help. > > Thanks in advance. |
My System Specs![]() |
| | #3 (permalink) |
| | Re: Deadlock when logging to stdout and stderr Many thanks Alex, This seems to be exactly the problem. So, now, I just have to implement this solution. Many thanks again, your link is really helpful. "Alex K. Angelopoulos" wrote: Quote: > I'm fairly certain that your problem here is that either your output or your > error buffer fills up while you're waiting for the other buffer, producing a > deadlock. See here for a brief description of the problem: > > http://blogs.msdn.com/lucian/archive...darderror.aspx > > The standard solution is to handle reading output and reading error from > distinct threads - something that I'm not well-acquainted with, but that > _can_ be done. Since this has been sitting here a week with no responses, > ping back if you're still trying to resolve this and I can do some more > looking. This problem definitely _can_ be solved. > > "Romuald" <Romuald@xxxxxx> wrote in message > news:A7E99F3E-BC07-4152-B66E-E5ED7F3803B5@xxxxxx Quote: > > Hi all, > > I created for my company a build and tests system which is mainly based on > > PS scripts. As we use it to build different langages (Java, C#, C++), my > > system uses external program to effectively run the builds and the tests. > > > > To run external software, I use a ProcessStartInfo object, like this: > > > > $si = New-Object -TypeName System.Diagnostics.ProcessStartInfo > > $si.FileName = "cvs.exe" > > $si.RedirectStandardOutput = $true > > $si.RedirectStandardError = $true > > $si.UseShellExecute = $false > > $si.RedirectStandardOutput = $true > > $si.RedirectStandardError = $true > > > > $p = [diagnostics.process]::Start($si) > > > > $output = $p.StandardOutput.ReadToEnd() > > $errors = $p.StandardError.ReadToEnd() > > > > $p.WaitForExit() > > > > Log-Message $log Info $output > > > > if($errors.Length -gt 0) > > { > > Log-Message $log ERROR $errors > > } > > > > I'm facing a pretty blocking issue with thr stderr and stdout redirection, > > in some case, when the amount of traces is pretty big, my PS script is > > blocked completely blocked. I checked the external program is well > > terminated, so the problem doesn't seem to come from external programs > > (which > > are pretty different) but from Powershell which doesn't handle redirection > > correctly. > > > > Or the error is on my side. > > > > I tried to remove the redirection and everything works well, if I ask the > > developer to stop their output traces during the test, same thing, > > everything > > works well. > > > > So, I'm here to find a little help. > > > > Thanks in advance. > |
My System Specs![]() |
| | #4 (permalink) |
| | Re: Deadlock when logging to stdout and stderr Which version of PowerShell are you using? PS1 or PS2? "Romuald" <Romuald@xxxxxx> wrote in message news ACDF798-C329-451C-B4C0-B93809EE23B3@xxxxxxQuote: > Many thanks Alex, > This seems to be exactly the problem. So, now, I just have to implement > this > solution. > > Many thanks again, your link is really helpful. > > "Alex K. Angelopoulos" wrote: > Quote: >> I'm fairly certain that your problem here is that either your output or >> your >> error buffer fills up while you're waiting for the other buffer, >> producing a >> deadlock. See here for a brief description of the problem: >> >> http://blogs.msdn.com/lucian/archive...darderror.aspx >> >> The standard solution is to handle reading output and reading error from >> distinct threads - something that I'm not well-acquainted with, but that >> _can_ be done. Since this has been sitting here a week with no responses, >> ping back if you're still trying to resolve this and I can do some more >> looking. This problem definitely _can_ be solved. >> >> "Romuald" <Romuald@xxxxxx> wrote in message >> news:A7E99F3E-BC07-4152-B66E-E5ED7F3803B5@xxxxxx Quote: >> > Hi all, >> > I created for my company a build and tests system which is mainly based >> > on >> > PS scripts. As we use it to build different langages (Java, C#, C++), >> > my >> > system uses external program to effectively run the builds and the >> > tests. >> > >> > To run external software, I use a ProcessStartInfo object, like this: >> > >> > $si = New-Object -TypeName System.Diagnostics.ProcessStartInfo >> > $si.FileName = "cvs.exe" >> > $si.RedirectStandardOutput = $true >> > $si.RedirectStandardError = $true >> > $si.UseShellExecute = $false >> > $si.RedirectStandardOutput = $true >> > $si.RedirectStandardError = $true >> > >> > $p = [diagnostics.process]::Start($si) >> > >> > $output = $p.StandardOutput.ReadToEnd() >> > $errors = $p.StandardError.ReadToEnd() >> > >> > $p.WaitForExit() >> > >> > Log-Message $log Info $output >> > >> > if($errors.Length -gt 0) >> > { >> > Log-Message $log ERROR $errors >> > } >> > >> > I'm facing a pretty blocking issue with thr stderr and stdout >> > redirection, >> > in some case, when the amount of traces is pretty big, my PS script is >> > blocked completely blocked. I checked the external program is well >> > terminated, so the problem doesn't seem to come from external programs >> > (which >> > are pretty different) but from Powershell which doesn't handle >> > redirection >> > correctly. >> > >> > Or the error is on my side. >> > >> > I tried to remove the redirection and everything works well, if I ask >> > the >> > developer to stop their output traces during the test, same thing, >> > everything >> > works well. >> > >> > So, I'm here to find a little help. >> > >> > Thanks in advance. >> |
My System Specs![]() |
![]() |
| Thread Tools | |
| |
Similar Threads | ||||
| Thread | Forum | |||
| Deadlock 2 shrinewars for vista help | Gaming | |||
| StdOut and StdErr reading... | VB Script | |||
| redirect powershell stdout to objShell.Exec.Stdout.ReadAll()( | PowerShell | |||
| Help! Reached a deadlock | Vista security | |||
| Catching stdout AND stderr | PowerShell | |||