[147224] trunk/base/src/pextlib1.0/system.c

Rainer Müller raimue at macports.org
Thu Mar 31 08:56:53 PDT 2016


On 2016-03-31 17:53, raimue at macports.org wrote:
> Revision: 147224
>           https://trac.macports.org/changeset/147224
> Author:   raimue at macports.org
> Date:     2016-03-31 08:53:21 -0700 (Thu, 31 Mar 2016)
> Log Message:
> -----------
> pextlib/system: ignore signals SIGINT/SIGQUIT
> 
> When a SIGINT/SIGQUIT was generated by the user during execution of a program,
> both the program and the waiting parent tclsh process got interrupted by
> a signal. However, the handler in the tclsh only generated an unpleasant error
> message that a SIGINT/SIGQUIT was received.
> 
> With this change, only the child will handle the signal, hopefully ending its
> execution. If the program handles SIGINT/SIGQUIT, it might still just terminate
> with a normal exit code, so there is no chance for us to determine that it was
> killed by a signal.

As only the foreground process gets the signal, we have no knowledge
that it was caused by the user. This means we will still handle this
like a failing command instead of aborting all operations. For example
during 'port sync', a Ctrl-C will only interrupt syncing of the current
source and afterwards we will continue with the next one.

A better way could be to handle SIGINT/SIGQUIT in a custom handler and
on reception of a signal, we would kill the child process and return the
error {POSIX SIG SIGINT} as result of SystemCmd. However, I am unsure
how we would force the child to terminate and if this can be done reliably.

Rainer


More information about the macports-dev mailing list