<div dir="ltr">Here&#39;s an example that I&#39;ve tested on my machine, pretty easy to do<br><br>






<div>
<span style="font-family:monospace"><span style="color:rgb(0,0,0);background-color:rgb(255,255,255)">cat script.sh
</span><br>#!/bin/bash
<br>myexit () {
<br>    echo &quot;Exiting my way&quot;
<br>    exit 0
<br>}                                                                                                                                                                                   <br>trap myexit INT                                                                                                                                                                     <br>                                                                                                                                                                                    <br>while true; do                                                                                                                                                                      <br>    echo alive                                                                                                                                                                      <br>    sleep 1                                                                                                                                                                         <br>done<br></span></div>


<br></div><div class="gmail_extra"><br><div class="gmail_quote">On Fri, Jul 17, 2015 at 1:04 PM, Alan W. Irwin <span dir="ltr">&lt;<a href="mailto:irwin@beluga.phys.uvic.ca" target="_blank">irwin@beluga.phys.uvic.ca</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span class="">On 2015-07-17 12:55-0700 Alan W. Irwin wrote:<br>
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
For PLplot I have implemented a fairly complex bash script that runs<br>
through a large series of tasks to do comprehensive testing of PLplot.<br>
The script calls its own special exit function whenever the script logic says<br>
it is time to exit, and that function among other tasks collects a<br>
convenient report tarball of carefully selected test results which makes<br>
it much easier for me to diagnose any PLplot problems that occur<br>
during the comprehensive testing.<br>
<br>
So far so good, but sometimes this script just hangs (e.g., on<br>
platforms which have buggy parallel builds such as MSYS and MSYS2) so<br>
the user has to interrupt it to get it to exit.  Can bash logic<br>
intercept such user interruptions and force exiting via the special<br>
exit function?<br>
<br>
One PLplot tester has just run into this problem so he has attempted<br>
to compensate by collecting all the useful bits and pieces by hand in<br>
a tarball.  But the results would be more reliable and also more<br>
convenient for him, if the script could automatically do that when it<br>
was interrupted.<br>
</blockquote>
<br></span>
Never mind.  I haven&#39;t tried it yet, but there is a straightforward<br>
example of bash interrupt handling at<br>
&lt;<a href="http://kb.mit.edu/confluence/pages/viewpage.action?pageId=3907156" rel="noreferrer" target="_blank">http://kb.mit.edu/confluence/pages/viewpage.action?pageId=3907156</a>&gt;<br>
which assuming it works should solve the above issue.<span class="HOEnZb"><font color="#888888"><br>
<br>
Alan</font></span><div class="HOEnZb"><div class="h5"><br>
<br>
<br>
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
Alan<br>
__________________________<br>
Alan W. Irwin<br>
<br>
Astronomical research affiliation with Department of Physics and Astronomy,<br>
University of Victoria (<a href="http://astrowww.phys.uvic.ca" rel="noreferrer" target="_blank">astrowww.phys.uvic.ca</a>).<br>
<br>
Programming affiliations with the FreeEOS equation-of-state<br>
implementation for stellar interiors (<a href="http://freeeos.sf.net" rel="noreferrer" target="_blank">freeeos.sf.net</a>); the Time<br>
Ephemerides project (<a href="http://timeephem.sf.net" rel="noreferrer" target="_blank">timeephem.sf.net</a>); PLplot scientific plotting<br>
software package (<a href="http://plplot.sf.net" rel="noreferrer" target="_blank">plplot.sf.net</a>); the libLASi project<br>
(<a href="http://unifont.org/lasi" rel="noreferrer" target="_blank">unifont.org/lasi</a>); the Loads of Linux Links project (<a href="http://loll.sf.net" rel="noreferrer" target="_blank">loll.sf.net</a>);<br>
and the Linux Brochure Project (<a href="http://lbproject.sf.net" rel="noreferrer" target="_blank">lbproject.sf.net</a>).<br>
__________________________<br>
<br>
Linux-powered Science<br>
__________________________<br>
_______________________________________________<br>
Discuss mailing list<br>
<a href="mailto:Discuss@vlug.org" target="_blank">Discuss@vlug.org</a><br>
<a href="http://lists.vlug.org/mailman/listinfo/discuss" rel="noreferrer" target="_blank">http://lists.vlug.org/mailman/listinfo/discuss</a><br>
<br>
</blockquote>
<br>
__________________________<br>
Alan W. Irwin<br>
<br>
Astronomical research affiliation with Department of Physics and Astronomy,<br>
University of Victoria (<a href="http://astrowww.phys.uvic.ca" rel="noreferrer" target="_blank">astrowww.phys.uvic.ca</a>).<br>
<br>
Programming affiliations with the FreeEOS equation-of-state<br>
implementation for stellar interiors (<a href="http://freeeos.sf.net" rel="noreferrer" target="_blank">freeeos.sf.net</a>); the Time<br>
Ephemerides project (<a href="http://timeephem.sf.net" rel="noreferrer" target="_blank">timeephem.sf.net</a>); PLplot scientific plotting<br>
software package (<a href="http://plplot.sf.net" rel="noreferrer" target="_blank">plplot.sf.net</a>); the libLASi project<br>
(<a href="http://unifont.org/lasi" rel="noreferrer" target="_blank">unifont.org/lasi</a>); the Loads of Linux Links project (<a href="http://loll.sf.net" rel="noreferrer" target="_blank">loll.sf.net</a>);<br>
and the Linux Brochure Project (<a href="http://lbproject.sf.net" rel="noreferrer" target="_blank">lbproject.sf.net</a>).<br>
__________________________<br>
<br>
Linux-powered Science<br>
__________________________<br>
_______________________________________________<br>
Discuss mailing list<br>
<a href="mailto:Discuss@vlug.org" target="_blank">Discuss@vlug.org</a><br>
<a href="http://lists.vlug.org/mailman/listinfo/discuss" rel="noreferrer" target="_blank">http://lists.vlug.org/mailman/listinfo/discuss</a><br>
</div></div></blockquote></div><br><br clear="all"><br>-- <br><div class="gmail_signature">Andrew Boktor<br></div>
</div>