On 05/08/2017 03:22, Bob Proulx wrote:
> Kevin Brodsky wrote:
>> $ bash -c '(trap "echo INT; exit 1" INT; sleep 60s); echo after'
>> ^CINT
>> after
>> $
> This is a good example of a bad example case.  You shouldn't "exit 1"
> or you will replace the information that the process is exiting due to
> a signal with an error code.  The trap handler should kill itself
> instead.  Use this test case instead.
>> $ bash -c '(trap "echo INT; trap - INT; kill -s INT $$" INT; sleep 60); echo 
>> after'
> Of course that doesn't change the end result here.  But at least the
> program exit WIFSIGNALED information is now correct.
> Signal handlers should always raise the signal on themselves after
> handling whatever they need to handle first.
> In any case I can't recreate your problem when using real processes in
> separate shells not all on one line.
> Bob

You're right Bob, I didn't think about the difference between exit()ing
and being kill()ed, notably in terms of WIFSIGNALED. Chet's reply
explains well the rationale, and it's now clear that the problem is on
Python's side (reproduced in my dummy example!).


Reply via email to