将stdout重定向到管道'挂起' [英] Redirect of stdout to pipe 'hangs'

查看:78
本文介绍了将stdout重定向到管道'挂起'的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Iam从事客户端,使用C ++在Linux上进行服务器编程。

我在后台运行服务器守护程序,我的客户端程序

与服务器进行通信并提取我在屏幕上打印的一些数据。这个东西工作正常但是当我重新定向

stdout到管道时它会挂起来永恒,


例如,


seema @ coma> simple_client |更多


如果我'杀死''服务器守护进程,那么控制最终会返回给shell的
。我需要让它工作,因为

我想将可执行文件与shell脚本集成。请问某人

请解释一下如何修理它?


预先谢谢

Seema

Iam working on Client, Server programming on Linux in C++.
I have a Server Daemon running in the background, my client program
talks to the Server and extracts some data which I
am printing on the screen. This thing works fine but when i redirect
the stdout to pipe it hangs for eternity,

for example,

seema@coma> simple_client | more

If I ''kill'' the Server Daemon, then control is eventually returned back
to the shell. I need to make it work because
i want to integrate executable with the shell script. Can somebody
please explain how to fix it?

Thanks in Advance
Seema

推荐答案

se ******** @ yahoo.co.in 写道:
我在客户端上工作,用C ++编写Linux上的服务器编程。
我在后台运行服务器守护程序,我的客户端程序
与服务器对话并提取我正在屏幕上打印的一些数据。这个东西工作正常但是当我将stdout重定向到管道时它会挂起来永恒,

例如,

seema @ coma> simple_client |更多

如果我'杀死''服务器守护进程,那么控制最终会返回给shell。我需要让它工作,因为我想将可执行文件与shell脚本集成。有人可以解释一下如何解决它吗?

提前致谢
Seema
Iam working on Client, Server programming on Linux in C++.
I have a Server Daemon running in the background, my client program
talks to the Server and extracts some data which I
am printing on the screen. This thing works fine but when i redirect
the stdout to pipe it hangs for eternity,

for example,

seema@coma> simple_client | more

If I ''kill'' the Server Daemon, then control is eventually returned back
to the shell. I need to make it work because
i want to integrate executable with the shell script. Can somebody
please explain how to fix it?

Thanks in Advance
Seema




请发布您的代码你希望我们帮助你。


另外,请不要过帖。如果您有c ++语言问题,请在此处发布

。如果它有问题,请在该新闻组中询问。


发布到此新闻组的规则可在
http://www.faqs.org/faqs/by-newsgrou....lang .c ++。html


- John Ratliff



Please post your code if you want us to help you with it.

Also, please don''t cross post. If you have a c++ language question, post
it here. If it''s a c question, ask it in that newsgroup.

Rules for posting to this newsgroup are available at
http://www.faqs.org/faqs/by-newsgrou....lang.c++.html

--John Ratliff


se ******** @ yahoo.co.in 写道:
我正在研究客户端,服务器编程Linux中的C ++。
我有一个服务器后台程序在后台运行,我的客户端程序与服务器对话并提取一些我在屏幕上打印的数据。这个东西工作正常但是当我将stdout重定向到管道时它会挂起来永恒,

例如,

seema @ coma> simple_client |更多

如果我'杀死''服务器守护进程,那么控制最终会返回给shell。我需要让它工作,因为我想将可执行文件与shell脚本集成。有人可以解释一下如何解决它吗?
Iam working on Client, Server programming on Linux in C++.
I have a Server Daemon running in the background, my client program
talks to the Server and extracts some data which I
am printing on the screen. This thing works fine but when i redirect
the stdout to pipe it hangs for eternity,

for example,

seema@coma> simple_client | more

If I ''kill'' the Server Daemon, then control is eventually returned back
to the shell. I need to make it work because
i want to integrate executable with the shell script. Can somebody
please explain how to fix it?




这可能是因为更多实用程序在输出之前读取整个文件

。所以,这里更多不会产生任何输出,直到

simple_client关闭其输出流(或退出关闭所有流)。



This is probably because more utility reads a whole file before
outputting it. So, here more does not produce any output until
simple_client closes its output stream (or exits closing all streams).



se********@yahoo.co.in 写道:


[]

se********@yahoo.co.in wrote:

[]
有人可以解释一下如何修复它吗?
Can somebody please explain how to fix it?




尝试使用less而不是更多。



Try using less instead of more.


这篇关于将stdout重定向到管道'挂起'的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆