Re: coprocess question



On 2006-12-21, Ronald <followait@xxxxxxx> wrote:
The program below is from APUE.
It is about coprocess.
Mainly, the parent deliver input to ``add2" through pipe A, and the
result is deliver back from ``add2" through pipe B.
The question is about stability, please search ``**" for it.

//** Here is the question:
//Is it possible that the result is
//more than one digit, but only
//one digit is read from the pipe?
//For example:
//input is ``11 22\nC-d"
//will the output be "3"?

in general yes, in this artificial case the result is most unlikely to be split.

static void sig_pipe(int signo)
{
printf("SIGPIPE caught\n");
exit(1);
}

that is most naughty. you shouldn't call printf from a signal, handler,
almost guaranteed to cause erattic, hard to find, problems.

Bye.
Jasen
.



Relevant Pages

  • coprocess question
    ... Mainly, the parent deliver input to ``add2" through pipe A, and the result is deliver back from ``add2" through pipe B. ... //one digit is read from the pipe? ...
    (comp.os.linux.development.apps)
  • pipe from child to parent: the parent exits, but the child does not
    ... Each child writes then the 3 fetched int values ... via the pipe to the parent. ... So I have prepared a simple test case program, which forks NKIDS ...
    (comp.unix.programmer)
  • Re: Python, Tkinter and popen problem
    ... but that is not `both way': popen connects the parent to the child ... The pipe works one way: from the child to the parent ... A child process always inherits stdin, stdout and stderr from the parent ...
    (comp.lang.python)
  • Re: Questions about perl daemons with child processes and open files / signals
    ... but not when used in the parent? ... process the pipe in the child process. ... The parent sits in the waitpid, waiting for the child to exit. ...
    (comp.lang.perl.misc)
  • Re: Trusted callers for command line programs
    ... Have a parent create a pipe before fork, ... to spoof once the bad guys catch on to what is being done. ... environment" of the command-line utility is if they can't trace/debug ...
    (comp.unix.programmer)