bug-bash
[Top][All Lists]
Advanced

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

Re: Script with set -m launched from interactive shell makes all ancesto


From: Chet Ramey
Subject: Re: Script with set -m launched from interactive shell makes all ancestor shells die
Date: Wed, 13 Aug 2014 16:40:38 -0400
User-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.9; rv:24.0) Gecko/20100101 Thunderbird/24.6.0

On 8/13/14, 12:42 PM, Greg Wooledge wrote:
> This was tested on bash 4.3.22 (HP-UX) and bash 4.2.37 (Linux).
> 
> Create a script named foo with the following content:
> 
> #!/bin/bash
> set -m
> while sleep 1; do :; done
> 
> Make it executable, and type
> 
> ./foo &
> 
> at an interactive shell.  You get your shell prompt back.  You can press
> Enter as many times as you like.  But if you press any key other than
> Enter, the entire terminal window goes away.

I haven't looked at this yet, but here's what I bet is happening: turning
on job control with set -m causes several things to happen: the shell
creates a new process group and becomes the process group leader, sets the
terminal's process group to its own process group, and creates children in
their own process group.

Now that the terminal is no longer in the parent shell's process group,
reads return EOF (or -1/EIO), and the parent shell exits.

The details may not be exactly this, but this is the general set of events.

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



reply via email to

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