redirecting stdin and stdout with pipes: convincing apps they're for a terminal?
I'm writing an application which will monitor standard input (for timeout). I'm currently attempting to do this by creating a pipe with pipe(2), and using that as the stdin and stdout for the child process (i.e. the process to be monitored).
(Before I continue: I'm running RedHat 8.0 on kernel 2.4.20-27.8.) However, running /bin/sh with this method causes sh to wait, and running /bin/vi causes vi to complain that input isn't from a terminal. How can I make my pipe act exactly as stdin and stdout would, no matter what the actual implementation of stdin and stdout was? Also: If I use the method detailed below, do I have to do anything special for child threads and processes of the monitored application? I'm assuming not, since it's my understanding that child processes inherit the stdin and stdout. Here's some code: Code:
void parent( pid_t* child ) { |
You need to use a pseudo-tty, look in the glibc manual for how to do that.
|
All times are GMT -5. The time now is 02:29 PM. |