Linux: Background process linked to terminal window

Solution 1:

You have to use the disown command (it may be specific to bash, not sure about it).

Example:

cmd &
disown

should do the trick.

If you want to reattach later the job to the terminal, use:

disown -h

Alternatively, you can use screen. Use it this way:

screen
cmd

Then, to go back to the terminal, hit ctrl+a, then d.

To come back to the screen, type in any terminal:

screen -r

Solution 2:

if you run nohup cmd &, so the program will ignore the SIGHUP it gets when the termial closes.