Windows Vista Forums
Vista Forums Home Join Vista Forums Windows 7 Forum Vista Tutorials Tags
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.

Go Back   Vista Forums > Misc Newsgroups > PowerShell

Vista - Deadlock when logging to stdout and stderr

Reply
 
Old 07-17-2009   #1 (permalink)
Romuald


 
 

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 SpecsSystem Spec
Old 07-25-2009   #2 (permalink)
Alex K. Angelopoulos


 
 

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 SpecsSystem Spec
Old 08-05-2009   #3 (permalink)
Romuald


 
 

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 SpecsSystem Spec
Old 08-07-2009   #4 (permalink)
Alex K. Angelopoulos


 
 

Re: Deadlock when logging to stdout and stderr

Which version of PowerShell are you using? PS1 or PS2?

"Romuald" <Romuald@xxxxxx> wrote in message
newsACDF798-C329-451C-B4C0-B93809EE23B3@xxxxxx
Quote:

> 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 SpecsSystem Spec
Reply

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


Vista Forums is an independent web site and has not been authorized,
sponsored, or otherwise approved by Microsoft Corporation.
"Windows Vista", the Start Orb, and related materials are trademarks of Microsoft Corp.
© Designer Media Ltd

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46