Re: named pipes programming problem
> Hi all,
> I'm new to the group and am seeking your advice on my Debian Linux C++
> programming problem with named pipes.
> Two programs are involved. One is myProgram.cc, which reads user's
> input from keyboard and prints to the screen. The other program
> is main.cc, which wants to communicate with myProgram in real time
> using input/output redirection and two named pipes.
> Now the problem is that main.cc works fine in one machine (sun4u, OS
> version 5.9, sparc, Ultra-60) but hangs in another machine running
> Debian Linux--the execution falls into infinite waiting at the first
> std::getline statement in main.cc. Could anyone suggest what the
> problem might be? The two programs are as follows:
I bet the problem is buffering. You do flush the output so that end
should not block. But the getline probably wants to read more than is
available and then blocks.
> char *mycmd="./myProgram <sicsin 2>sicsout >sicsout &";
You should use normal pipes here with fork/exec. Open a pair of pipes,
fork, close the right in/out ends in the parent and child, exec the
myProgram in the child. This might solve the deadlock as well.