Spawned procs should inherit goreman's stdin#140
Conversation
What happen for this? It is not guaranteed which one will be called first? |
|
Yep, there are no guarantees, the point is not to guarantee which tool gets to read from stdin the point is to 1. match how foreman works, 2. provide for tools that expect to be run via a tty. |
|
My example was to demonstrate that the processes foreman starts inherit foreman's stdin, not to enable some kind of specific ordering of stdin behavior. |
|
Is it a specification that foreman handles standard input? If so, please show me the specification or the source code that intentionally implements it. I can't implement it without specification. |
|
Here's the code: https://github.com/ddollar/foreman/blob/1445adc429d79b5b3dd1d54cf9dcb75d253c924f/lib/foreman/process.rb#L54 Foreman uses Since the docs for Tada! Proof that foreman spawns processes such that they all inherit stdin from the main foreman process. I've also demonstrated that this matters to some processes. |
|
is this going forward ? stdin is really useful feature. I guess you would all agree. |
|
Thank you, and sorry for the late response. I tested this and the piped case works as advertised: $ cat Procfile
web: read user && echo "Hello, $user"
$ echo cora | goreman start
10:27:10 web | Hello, coraHowever, when goreman runs on an interactive terminal it hangs: subprocesses are placed in their own process group ( $ timeout 5 script -qec "goreman start" /dev/null < /dev/null
# web stops on SIGTTIN, goreman hangs until killedSo this needs some handling for the TTY case before it can be merged — e.g. only inherit stdin when it is not a terminal, or gate it behind a flag. |
Processes spawned via
foremaninherit stdin from it. You can test this like so:Why does this matter? Because some things care if stdin is a TTY or
/dev/null(the previous stdin value for all launched procs):You could always redirect
/dev/nullinto your processes if that's what you want but forcing them to inherit your terminal's TTY is impossible if goreman is inserting/dev/nullas stdin and so I think this is the better default.Thoughts?