问题
I'd like to be able to launch a process from a GUI application (right now I'm thinking specifically of letting an eclipse user -- possibly via a plugin -- click a button to launch a build using my organization's build system).
I don't want this process to stop when I stop the parent application, and I want to be able to "switch into it" later, as though I launched it from a command line.
I've seen GNU screen described as good for most of what I'm asking for, but I'm not sure about the "launch the process from another application" part.
Can this be done if the GUI application was itself launched from within screen? Can this be done if it wasn't? I'd be very interested in seeing how!
Update: Prepending "screen" to a command line looks like a good way to start a process in screen from a shell, but I'm trying to find a way to do this without being taken straight into that session. I want to "send" the command to a screen session, where it will be started in a new window in that session.
回答1:
simply prepend the 'screen' command to your normal commandline.
E.g. if you normally execute "./make_build.sh opt1 opt
" then your screenified commandline would be "screen ./make_build.sh opt1 opt2
"
Its that easy! :-)
回答2:
You can send screen messages to a running screen session with the -X flag.
See How to start a new process in a new window in an existing GNU screen session, from outside the session or the screen man pages.
回答3:
If you can suspend the process (via Cont-Z) you can then run
screen -dr -X screen $(fg)
It will attach that process to a new window in the screen. Its not ideal, but it will work.
来源:https://stackoverflow.com/questions/1220797/how-to-start-a-process-from-another-application-and-then-open-a-terminal-to-that