Hello,

I am trying to figure out the meaning of:

        /proc/$PID/fd/*

files.

As:
- their name suggests
- as most of the descriptions on the web around indicate
- and consistently with wishful thinking
I thought that writing to /proc/$PID/0 would mean that designated process will receive the written date.

To verify this, I wrote a small program:

  -------------------------------------
  #include <unistd.h>

  char buf[10];

  int main()
  {
        unsigned u = read(0, buf, 10);
        write(1, buf, u);
        return 0;
  }
  -------------------------------------

ran it:

  ./main

and then if I tried something like this:

  echo "foo" > /proc/$PID/fd/0

the expectation were that the process would be able to read 4 bytes from its standard input.

  'f', 'o', 'o', '\n'

What actually happened was:
- "foo" string appeared on the appropriate terminal
- the "./main" process remained blocked in the "read" system call.

Is there somewhere a concise and correct description that explains this?


--
To UNSUBSCRIBE, email to debian-user-requ...@lists.debian.org with a subject of "unsubscribe". Trouble? Contact listmas...@lists.debian.org
Archive: http://lists.debian.org/51235ae0.4040...@gmail.com

Reply via email to