question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Command.StandardOutput.ReadToEnd() hangs every time

See original GitHub issue
    Process.GetProcessesByName("adb").ToList().ForEach(x => x.Kill());
    var arguments = new List<string> { "connect", "127.0.0.1:21503" };
    var command = Command.Run("adb.exe", arguments,
        options => options.Timeout(TimeSpan.FromMinitues(1)));
    var output = command.StandardOutput.ReadToEnd();
    var error = command.StandardError.ReadToEnd();

adb.exe is is Android Debug Bridge

  1. the code snippet hangs every time with adb.exe version 1.0.31
  2. options.Timeout does not work, the underline process still running after 1 minute
  3. the code snippet works well with adb.exe version 1.0.39

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:16 (14 by maintainers)

github_iconTop GitHub Comments

1reaction
compucorsscommented, Dec 19, 2017

Sorry, I should’ve mentioned that it had nothing to do with the code above. Was just commenting about a separate problem that I had. Can’t get to the machine now, but I was working on a local installment trying to call out to a GET API of a vendor. I will post the code if you’re interested later. Thanks!

0reactions
madelsoncommented, Dec 19, 2017

@compucorss I’m not sure I follow your scenario. Was the HttpRequest without the proxy setting happening in the external process? What was the connection to StandardOut? In general, ReadToEnd() cannot return until the external process either closes StandardOut or, more likely, exits. Therefore anything that would cause the external process to hang (e. g. an infinite loop, deadlock, etc) will cause ReadToEnd() to hang.

Read more comments on GitHub >

github_iconTop Results From Across the Web

StandardOutput.ReadToEnd() hangs [duplicate]
The problem is that you are using the synchronous ReadToEnd methods on both the StandardOutput and the StandardError streams. This can lead to...
Read more >
[Solved]-StandardOutput.ReadToEnd() hangs-C#
This code snippet worked for me. The problem is that you are using the synchronous ReadToEnd methods on both the StandardOutput and the...
Read more >
[Solved] StandardOutput.ReadLine Freezes
Hey there, Deadlocks are a common issue when working with RedirectStandardInput & Output. The way to avoid this is to close the RedirectIO....
Read more >
Process.StandardOutput Property (System.Diagnostics)
A deadlock condition results if the parent process calls p.StandardOutput.ReadToEnd followed by p.StandardError.ReadToEnd and the child process writes enough ...
Read more >
Winscp process hangs in vb.net code - Works in one ...
ReadToEnd() command. We are using this as a process to call winscp.com inside a vb.net function with saved session. saved sessions are stored...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found