[Top][All Lists]

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

Re: Background job started from .bashrc is killed by ctrl-z from prompt

From: Chet Ramey
Subject: Re: Background job started from .bashrc is killed by ctrl-z from prompt
Date: Sat, 04 May 2013 19:45:29 -0400
User-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.8; rv:17.0) Gecko/20130328 Thunderbird/17.0.5

On 5/1/13 6:53 AM, address@hidden wrote:

> Machine Type: x86_64-unknown-linux-gnu
> Bash Version: 4.2
> Patch Level: 45
> Release Status: release
> Description:
>       I know this is something odd to do, I would like to start my windows 
> manager
> from .bashrc.
>       If I do so and hit ctrl-z while bash is asking me for command line, the 
> job is
> suspended.
>       I can't resume it : "bash: bg: job 1 started without job control"

Here's what happens: the startup files are run without job control enabled.
All processes started when job control is not enabled are in the same
process group as the shell itself, and do not ignore job control signals
(SIGTTIN/SIGTTOU/SIGTSTP) so they can be controlled later.  Since they are
not in separate process groups, they can't be individually moved between
the foreground and background using the set of job control builtins.

The shell ignores SIGTSTP, so a ^Z from the command line won't suspend it
inadvertently.  Since keyboard-generated signals are sent to the terminal's
foreground process group, the asynchronous job run from .bashrc receives
the SIGTSTP and stops.

You can send SIGCONT to the backgrounded process's pid to continue it.  If
you want to play around with your startup files, you can try starting the
window manager in the background from a subshell in which you've enabled
job control with `set -m'.

``The lyf so short, the craft so long to lerne.'' - Chaucer
                 ``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, ITS, CWRU    address@hidden    http://cnswww.cns.cwru.edu/~chet/

reply via email to

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