Bryan Kearney
2008-Dec-08 15:12 UTC
[Ovirt-devel] [PATCH node] Allow the init scripts to handle ctrl-c well
From: Bryan Kearney <bkearney at localhost.localdomain> --- scripts/ovirt-functions | 7 +++++++ 1 files changed, 7 insertions(+), 0 deletions(-) diff --git a/scripts/ovirt-functions b/scripts/ovirt-functions index c6a8504..f641ea0 100644 --- a/scripts/ovirt-functions +++ b/scripts/ovirt-functions @@ -2,6 +2,13 @@ OVIRT_LOGFILE=/var/log/ovirt.log +# handle ctrl-c gracefully +trap 'dropout' INT + +dropout() { + exit 0 +} + # label of the oVirt partition OVIRT_LABEL=OVIRT # configuration defaults -- 1.6.0.4
Jim Meyering
2008-Dec-08 17:57 UTC
[Ovirt-devel] [PATCH node] Allow the init scripts to handle ctrl-c well
Bryan Kearney <bkearney at redhat.com> wrote:> From: Bryan Kearney <bkearney at localhost.localdomain> > > --- > scripts/ovirt-functions | 7 +++++++ > 1 files changed, 7 insertions(+), 0 deletions(-) > > diff --git a/scripts/ovirt-functions b/scripts/ovirt-functions > index c6a8504..f641ea0 100644 > --- a/scripts/ovirt-functions > +++ b/scripts/ovirt-functions > @@ -2,6 +2,13 @@ > > OVIRT_LOGFILE=/var/log/ovirt.log > > +# handle ctrl-c gracefully > +trap 'dropout' INT > + > +dropout() { > + exit 0 > +}Hi Bryan, What's the motivation for this addition? It would make it so interrupting any script that sources ovirt-functions would cause it to exit _successfully_. And if some other program examines the script's exit status (like Make or another shell script), then it will be misled into thinking that the interrupted script succeeded. Even changing it to exit nonzero would be misleading, since that would hide the fact that the script had been terminated by a signal (which is normally indicated via the exit status).