Re: /proc/PID/fd/0 design "bug"

Michael O'Reilly (michael@metal.iinet.net.au)
22 Dec 1997 09:56:07 +0800


Lars Marowsky-Bree <lmb@pointer.teuto.de> writes:
> --MzawGl8SdtHY/0P4
> Content-Type: text/plain; charset=us-ascii
> Content-Transfer-Encoding: quoted-printable
>
> On 1997-12-21T16:13:58,
> "Pawel S. Veselov" <vps@unicorn.niimm.spb.su> said:
>
> > /proc/PID/fd has rights of user.group this process is run.=20
> > So you only can affect your own processes. ( assuming you are not root )
>
> Even as root I am not able to use /proc/PID/fd/0 to stuff arbitary input
> into any program.
>
> This SHOULD work and has useful applications (it would allow some of the
> ugly gpm hacks in the kernel to go away)

No, you're engaging in minor thinko here. When you do
echo blah > /proc/PID/fd/0

You're acting as tho you where process PID. I.e. as if process PID had
done a write(0, "blah\n", 5);

which isn't what you want at all. What you want to is find the process
that is actually writing out, (i.e. the other end of the pipe or
whatnot) and do your write there.

Of course, this fails for processes reading from devices or files.

Michael.