This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH] posix: Add SIGSEGV on the trap list for globtest.sh



On 11/04/2017 18:12, Florian Weimer wrote:
> On 04/11/2017 09:59 PM, Adhemerval Zanella wrote:
>>
>>
>> On 11/04/2017 15:22, Florian Weimer wrote:
>>> On 04/11/2017 08:09 PM, Adhemerval Zanella wrote:
>>>> -trap 'chmod 777 $testdir/noread; rm -fr $testdir $testout' 1 2 3 15
>>>> +trap 'chmod 777 $testdir/noread; rm -fr $testdir $testout' HUP INT QUIT SEGV TERM
>>>
>>> Does the shell really receive the signal?  Why not use “0”?
>>
>> It does not off course since it is not the shell that is actually generating
>> the segfault.
> 
> Well, the shell uses globbing, too, so who knows. :)
> 
>> I will rewrite the patch.
> 
> Thanks.  Using 0 is probably the correct choice, then.
> 
> Florian

Ok, here is a version 2.

--

This patch prevents lingering files for SIGSEGV failures by adding
a cleanup handler on trap handler.  Checked on x86_64-linux-gnu.

	* posix/globtest.sh: Add cleanup for the signal to act on a trap.

---
 ChangeLog         |  4 ++++
 posix/globtest.sh | 10 +++++++---
 2 files changed, 11 insertions(+), 3 deletions(-)

index f9cc80b..a764aef 100755
--- a/posix/globtest.sh
+++ b/posix/globtest.sh
@@ -47,7 +47,13 @@ testout=${common_objpfx}posix/globtest-out
 rm -rf $testdir $testout
 mkdir $testdir
 
-trap 'chmod 777 $testdir/noread; rm -fr $testdir $testout' 1 2 3 15
+cleanup()
+{
+  chmod 777 $testdir/noread
+  rm -fr $testdir $testout
+}
+
+trap cleanup 0 HUP INT QUIT TERM
 
 echo 1 > $testdir/file1
 echo 2 > $testdir/file2
@@ -811,8 +817,6 @@ if test $failed -ne 0; then
 fi
 
 if test $result -eq 0; then
-    chmod 777 $testdir/noread
-    rm -fr $testdir $testout
     echo "All OK." > $logfile
 fi


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]