I have detached a process from my terminal, like this:
$ process &
That terminal is now long closed, but process is still running and I want to send some commands to that process's stdin. Is that possible?
Yes, it is. First, create a pipe:
Then close stdin:
Finally, write away (from a different terminal, as gdb will probably hang):
I am quite sure you can not.
In this example, you can send input to
EDIT : As Stephane Gimenez said, it's not that simple. It's only allowing you to print to a different terminal.
You can try to write to this process using /proc. It should be located in /proc/pid/fd/0, so a simple :
should do it. I have not tried it, but it should work, as long as this process still has a valid stdin file descriptor. You can check it with
See nohup for more details about how to keep processes running.
Just ending the command line with
When a process runs in the background, it won't receive input from its controlling terminal anymore. But you can send it back into the foreground with
Otherwise, it's not possible to externally change its filedescriptors (including stdin) or to reattach a lost controlling terminal… unless you use debugging tools (see Ansgar's answer, or have a look at the