<div dir="ltr"><div class="gmail_extra"><br><div class="gmail_quote">On Sat, Jun 14, 2014 at 10:25 PM, Ian Wadham <span dir="ltr">&lt;<a href="mailto:iandw.au@gmail.com" target="_blank">iandw.au@gmail.com</a>&gt;</span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div id=":3bm" class="a3s" style="overflow:hidden">The procedure for closing the file descriptors is a bit brute force.  It uses<br>

&quot;struct rlimit rlp; getrlimit(RLIMIT_NOFILE, &amp;rlp);&quot; to find out how many<br>
open files the user is allowed (my system says 2560) and then does<br>
&quot;close();&quot; on ALL of them except 0, 1and 2 (stdin, etc.).<br>
<br>
I thought that might be causing the second signal - there are only about<br>
10 descriptors open - but it still happens even when I insert a test for a<br>
valid file descriptor (&quot;if (fcntl(i, F_GETFL) != -1)&quot;) and end the loo when<br>
I get to an invalid one.  I know - not perfect … ;-)<br></div></blockquote></div><br>Where exactly is it receiving the signal?</div><div class="gmail_extra"><br></div><div class="gmail_extra">Beware of thread stacks, which may be in the heap; if the per-thread stack size is too small, you will definitely see things like this and stack allocation/extension in the SEGV handler (like, that struct rlimit) will make it worse unless you use sigaltstack.</div>
<div class="gmail_extra"><br>-- <br><div dir="ltr"><div>brandon s allbery kf8nh                               sine nomine associates</div><div><a href="mailto:allbery.b@gmail.com" target="_blank">allbery.b@gmail.com</a>                                  <a href="mailto:ballbery@sinenomine.net" target="_blank">ballbery@sinenomine.net</a></div>
<div>unix, openafs, kerberos, infrastructure, xmonad        <a href="http://sinenomine.net" target="_blank">http://sinenomine.net</a></div></div>
</div></div>