[Top][All Lists]

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

Re: [Help-bash] Does the parent get the trap signal when the child is ru

From: Chet Ramey
Subject: Re: [Help-bash] Does the parent get the trap signal when the child is running in the foreground?
Date: Tue, 11 Dec 2018 11:01:44 -0500
User-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.14; rv:52.0) Gecko/20100101 Thunderbird/52.9.1

On 12/10/18 12:25 PM, Peng Yu wrote:
> Hi,
> I am not sure if I understand the traps related with parent and child
> processes correctly.
> I press Ctrl-C 5 times. The child gets SIGINT 5 times and the parent
> gets 1 once. But since Ctrl-C triggers SIGINT for the process group
> whose leader is the process started by, why only
> gets one signal? Thanks.

The parent receives 5 SIGINTs, but only runs the trap once, when the
child process completes.

Read for more insight about the

The parent shell shouldn't really do anything, since the child -- the
foreground process -- caught the SIGINT, handled it, and did not exit as a
result. However, backwards compatibility and user expectations being what
they are, the parent shell ( runs the SIGINT trap as well.

``The lyf so short, the craft so long to lerne.'' - Chaucer
                 ``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, UTech, CWRU    address@hidden

reply via email to

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