如何判断进程挂起是否是由于缓冲区已满(TCP、stdin、stdout)所致?
我有一个 C# 应用程序,它在单独的进程中启动控制台应用程序。这两个应用程序通过 TCP 连接以及一些(有限的)标准输入/输出进行通信。我遇到的问题是,每当我在调试器中“中断”时,它似乎都会导致控制台应用程序挂起。如果我不理会这两个应用程序,它们都可以正常工作,并且它们之间的交互似乎没有问题。
到目前为止,我的研究似乎表明,由于输出缓冲区已满,我可能会遇到死锁情况。我如何验证情况确实如此?对于导致此问题的原因还有其他解释吗?
I've got a C# application which launches a console application in a separate process. The two applications communicate via a TCP connection, as well as some (limited) standard input/output. The problem I'm experiencing is that whenever I "break" within the debugger, it seems to cause the console application to hang. If I leave the applications alone, both work just fine, and there appear to be no problems in the interaction between them.
My research so far seems to indicate that I might be hitting a deadlock condition, due to the output buffers being filled. How can I verify that this is indeed the case? Are there any other explanations for what would be causing this problem?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果您怀疑某处调用被阻塞,您可以尝试查看是否有异步版本(带有回调);或者,在线程内手动启动它,然后让主线程在循环中休眠,直到超时;如果在此之前尚未完成,则抛出异常。
If you suspect a call is blocking somewhere, you could try to see if there's an asynchronous version (with a callback); or otherwise, manually launch it inside a thread, and then have the main thread sleep in a loop until some timeout; and throw an exception if it doesn't complete until then.