help-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Help-bash] Automatically "disown -h" all background jobs


From: R. Diez
Subject: [Help-bash] Automatically "disown -h" all background jobs
Date: Tue, 1 Aug 2017 14:31:59 +0200
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.2.1

Hi all:

It happens to me all the time: I start a background GUI job with &, like "git gui &", I then close the terminal window with the mouse, and the GUI job is gone with it. However, quitting with "exit" leaves background jobs running fine. At least that is the default behaviour in many distros.

I know about SIGHUP, nohup, huponexit, disown, etc. But they do not really help, or I just cannot remember to use the right one every time. It's annoying.

I am not the only one who has noticed:

https://unix.stackexchange.com/questions/284673/automatically-disown-application-when-running-it-from-a-terminal

But the proposed solution would mean having to remember something new, and my muscle memory strongly disagrees.

What I need is a new option in Bash to stop forwarding SIGHUP to background jobs. The foreground job should still get it though.

I tried trapping SIGHUP for a while in .bashrc , but that left foreground processes like "less </dev/null" running in the background when I forcibly closed the Emacs multi-term frame Bash and 'less' were running in. So completely blocking SIGHUP is not a good solution for all situations.

I am using PROMPT_COMMAND="disown -a -h" at the moment, but this trick is not elegant enough for me. 8-)

Regards,
  rdiez



reply via email to

[Prev in Thread] Current Thread [Next in Thread]