bug-bash
[Top][All Lists]
Advanced

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

Re: bug in force_interactive handling


From: Chet Ramey
Subject: Re: bug in force_interactive handling
Date: Mon, 02 Jan 2012 15:07:26 -0500
User-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.6; rv:8.0) Gecko/20111105 Thunderbird/8.0

On 1/2/12 2:10 PM, Stas Sergeev wrote:

>>> Will your suggestion about the trap handler work
>>> also for ^Z+bg rather than just fg?
>> It should.
> I tried:
> ---
> trap bg USR1
> ---
> Now if I first send SIGSTOP to the job and then SIGUSR1 to
> bash, that works.
> Is it possible to avoid sending SIGSTOP to the job, and make
> the trap handler to do both things at once? Not that it is strictly
> required since you already described a few other ways, but I wonder. :)

Well, this is getting pretty esoteric.  On one hand, you can avoid the
entire SIGSTOP/SIGCONT issue by initially starting the job in the
background with `&'.  On the other, if you want to move a foreground
job to the background, you have to get it to give up control somehow, and
sending it a signal is the way to do that.

You can install a trap handler for another signal, say SIGALRM, and have
some process send SIGALRM to the shell after some period (e.g.,
`( sleep 20 ; kill -ALRM $$)' ), but you'll have to get the shell to react
to the signal once it's received rather than waiting for the foreground
process to change state.  Once you get the shell running, it can issue
the SIGSTOP/bg.

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]