[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Help-bash] `eval' subprocess not terminated
From: |
Chet Ramey |
Subject: |
Re: [Help-bash] `eval' subprocess not terminated |
Date: |
Thu, 06 Feb 2014 08:36:43 -0500 |
User-agent: |
Mozilla/5.0 (Macintosh; Intel Mac OS X 10.8; rv:24.0) Gecko/20100101 Thunderbird/24.1.1 |
On 2/6/14 3:33 AM, Ion Savin wrote:
> Hi Matthew,
>
>>> I'm launching a script which is using `eval' to start a long running
>>> process (just as an example I'll use xeyes):
>>>
>>> $ cat test.sh
>>> #!/bin/bash
>>> eval xeyes
>>>
>>> $ ./test.sh
>>>
>>> From another terminal I kill the shell process:
>>>
>>> $ kill -9 `ps h --format pid -C "test.sh"`
>>>
>>> The shell process terminates but the child process is not killed. Is
>>> there any way to force bash (I'm using ver. 4.2.45) to terminate the
>>> `eval' subprocesses it has created?
>>
>> Why do you need eval at all? Are you sure you don't mean to be using
>> exec?
>
> In the real world scenario test.sh is actually one of many third party
> scripts each of which could contain `eval'. This is why I would prefer to
> find a solution which works without any changes to the script itself if
> possible.
Killing a single process, especially when you use SIGKILL, doesn't affect
any of the other processes in the same process group. If you negate the
pid, kill will send the signal to all processes who have the absolute
value of that process number as their process group ID. Try
kill -9 -$(ps h --format pid -C "test.sh")
instead.
--
``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/