Jay Taylor's notes
back to listing indexHow do I detach a process from Terminal, entirely?
[web search]
I use Tilda (drop-down terminal) on Ubuntu as my "command central" - pretty much the way others might use GNOME Do, Quicksilver or Launchy. However, I'm struggling with how to completely detach a process (e.g. Firefox) from the terminal it's been launched from - i.e. prevent that such a (non-)child process
For example, in order to start Vim in a "proper" terminal window, I have tried a simple script like the following:
However, that still causes pollution (also, passing a file name doesn't seem to work).
|
|||||||||||||||||||||||||||
migrated from stackoverflow.com Aug 21 '10 at 4:05This question came from our site for professional and enthusiast programmers. |
|||||||||||||||||||||||||||
|
|||||||||||||||||||||||||||
First of all; once you've started a process, you can background it by first stopping it (hit Ctrl-Z) and then typing You can start a process as backgrounded immediately by appending a "&" to the end of it:
To run it in the background silenced, use this:
Some additional info:
What you can't do, is change the stdout/stderr/stdin of a process after having launched it. At least not from the shell. If you launch your process and tell it that its stdout is your terminal (which is what you do by default), then that process is configured to output to your terminal. Your shell has no business with the processes' FD setup, that's purely something the process itself manages. The process itself can decide whether to close its stdout/stderr/stdin or not, but you can't use your shell to force it to do so. To manage a background process' output, you have plenty of options from scripts, "nohup" probably being the first to come to mind. But for interactive processes you start but forgot to silence ( I recommend you get GNU Oh, and by the way, don't use "
That's probably not what you want because -e only takes one argument. Use It's really difficult to get multiple arguments working properly in the scenario that you gave (with the
|
|||||||||||||||||||||||||||||||||
|
|
|||||||||||||||||||||||||||||||||
|
If you are using Another approach you can try is
|
|||||||||||||||||||||||||||||||||
|
Reading these answers, I was under the initial impression that issuing In my case,
or
if you prefer one-liners. This has the generally desirable effect of removing the subprocess from the jobs table. This allows you to exit the terminal emulator without accidentally signaling the child process at all. No matter what the After the disown, the process is still a child of your terminal emulator (play with What to do if your shell does not support
|
|||
I've been using number 2 for a very long time, but number 3 works just as well. Also, disown has a 'nohup' flag of '-h', can disown all processes with '-a', and can disown all running processes with '-ar'. Silencing is accomplished by '$COMMAND &>/dev/null'. Hope this helps!
|
|||||||||
|
in tcsh (and maybe in other shells as well), you can use parentheses to detach the process. Compare this:
To this:
This removes firefox from the jobs listing, but it is still tied to the terminal; if you logged in to this node via 'ssh', trying to log out will still hang the ssh process.
|
||||
You can run your command using the nohup command, this detach your process and redirects outputs to a given file... but I am not sure that is exactly what you need ..
|
|||||||||
|
To disassociate tty shell run command through sub-shell for e.g. (command)& When exit used terminal closed but process is still alive. check -
Open other terminal
Process is still alive.
|
|||||||||
|
Backgrounding and foregrounding a job is probably one of the very first things every Unix sys-admin should know. Here is how it is done:
|
||||
In my .bashrc, I have these functions for precisely that purpose:
Prefix a command with The function is written to work with
|
|||||||||||||||
|
I use the following script to do this. It stops the process printing to the terminal, detaches with
Usage example:
|
|||
Your Answer
Technology | Life / Arts | Culture / Recreation | Science | Other | ||||||
---|---|---|---|---|---|---|---|---|---|---|