How to write to stdin of another process?
From: Paul (pg_x_at_yahoo.com)
Date: 03/27/05
- Next message: Samik Raychaudhuri: "Nice question: what happens to child?"
- Previous message: Alan Connor: "Re: rsync over http?"
- In reply to: Jeremiah DeWitt Weiner: "Re: How to write to stdin of another process?"
- Next in thread: Barry Margolin: "Re: How to write to stdin of another process?"
- Reply: Barry Margolin: "Re: How to write to stdin of another process?"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Sun, 27 Mar 2005 14:25:37 +0300
Jeremiah DeWitt Weiner wrote:
> Paul <pg_x@yahoo.com> wrote:
>> if I have the PID of another already running process is it possible to
>> write to its stdin? I guess it is possible so the question is HOW?
>
> To an arbitrary process, which was not started in any special way?
> No.
Are you sure? Those processes still have stdin. Foreground processes read
from the terminal. Background processes have their stdin connected to some
created especially for them internal pipes:
# ls /proc/31905/fd/
lr-x------ 1 p p 64 2005-03-27 14:04 0 -> pipe:[126663]
It should be possible to somehow get the pipe and write to it?
> There are ways to do it if you can control how the process starts,
> though. For example, you could create a FIFO and make the process take
> input from it, then write data to the FIFO. Using "screen" might also
> do what you want, depending on what your requirements are.
>
>
>> I managed to send data to the stdin file of the process and it was
>> displayed in the console where the process was running but it wasn't
>> actually read by the process :(
>
> Correction: you managed to send data to the terminal which was
> stdin and stdout of the process. That's not the same thing as sending
> it to the stdin of the process, as you discovered.
>
> Xposted and f'ups set, since this is not really an admin-type question.
>
> JDW
sorry for multiposting. didn't know i shouldn't. won't do it again
-- There are 10 types of people - those who understand binary and those that don't
- Next message: Samik Raychaudhuri: "Nice question: what happens to child?"
- Previous message: Alan Connor: "Re: rsync over http?"
- In reply to: Jeremiah DeWitt Weiner: "Re: How to write to stdin of another process?"
- Next in thread: Barry Margolin: "Re: How to write to stdin of another process?"
- Reply: Barry Margolin: "Re: How to write to stdin of another process?"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|