send to stdin per PID

e.g. send to a program’s stdin via its PID.


#include <stdio.h>

int main(){
    char buffer[1000];
    while (1){
        scanf("%s", buffer);
        printf("%s\n", buffer);

    return 0;

Comiple and run the test. To send iostream to this program from elsewhere (e.g. another terminal):

echo something > /proc/<PID>/fd/0

Don’t try to read from program’s stdout/err (e.g. cat /proc/<PID>/fd/{1,2}), because the buffer could be consumed by other “listeners” and results will be inconsistent.

not so easy! [WIP]