groff-commit
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[groff] 23/23: [groff]: Revise test script's signal handling.


From: G. Branden Robinson
Subject: [groff] 23/23: [groff]: Revise test script's signal handling.
Date: Thu, 3 Oct 2024 07:22:34 -0400 (EDT)

gbranden pushed a commit to branch master
in repository groff.

commit ca9f376362349a71e8ea0fff4b700e91de6de04a
Author: G. Branden Robinson <g.branden.robinson@gmail.com>
AuthorDate: Thu Oct 3 02:53:19 2024 -0500

    [groff]: Revise test script's signal handling.
    
    * src/roff/groff/tests/write-request-handles-empty-second-arg.sh: Revise
      signal handling.
    
    This stuff is why I try to avoid signal handlers in the shell (and
    consequently, messing with temporary files).
    
    See https://www.cons.org/cracauer/sigint.html for a face-melting survey.
---
 ChangeLog                                                   |  6 ++++++
 .../groff/tests/write-request-handles-empty-second-arg.sh   | 13 ++++++++++++-
 2 files changed, 18 insertions(+), 1 deletion(-)

diff --git a/ChangeLog b/ChangeLog
index e5f8de458..7eb3fbd63 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2024-10-03  G. Branden Robinson <g.branden.robinson@gmail.com>
+
+       * src/roff/groff/tests/\
+       write-request-handles-empty-second-arg.sh: Revise signal
+       handling.
+
 2024-09-27  G. Branden Robinson <g.branden.robinson@gmail.com>
 
        * src/roff/troff/input.cpp (class input_iterator)
diff --git a/src/roff/groff/tests/write-request-handles-empty-second-arg.sh 
b/src/roff/groff/tests/write-request-handles-empty-second-arg.sh
index 4e79b9592..51848bca4 100755
--- a/src/roff/groff/tests/write-request-handles-empty-second-arg.sh
+++ b/src/roff/groff/tests/write-request-handles-empty-second-arg.sh
@@ -35,7 +35,18 @@ cleanup () {
   rm -f $tmpfile
 }
 
-trap 'trap - HUP INT QUIT TERM; cleanup; kill -INT $$' HUP INT QUIT TERM
+# A process handling a fatal signal should:
+#   1.  Mask _all_ fatal signals.
+#   2.  Perform cleanup operations.
+#   3.  Unmask the signal (removing the handler).
+#   4.  Signal its own process group with the signal caught so that the
+#       the children exit and shell accurately reports how the process
+#       died.
+fatals="HUP INT QUIT TERM"
+for s in $fatals
+do
+  trap "trap '' $fatals; cleanup; trap - $fatals; kill -$s -$$" $s
+done
 
 input='.
 .open mystream '$tmpfile'



reply via email to

[Prev in Thread] Current Thread [Next in Thread]