From 7e7e43cbcd097fd9d6b7045c646f486cca1bf148 Mon Sep 17 00:00:00 2001 From: Ola Date: Wed, 12 Aug 2020 20:40:26 +1000 Subject: [PATCH] Adding in SendSignal example. --- expect_test.go | 4 ++-- testdata/traptest.sh | 11 +++++++---- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/expect_test.go b/expect_test.go index acacc89..b9d0a51 100644 --- a/expect_test.go +++ b/expect_test.go @@ -1329,7 +1329,7 @@ func ExampleGExpect_SendSignal() { return } - reExpect, err := regexp.Compile("Sig USR1") + reExpect, err := regexp.Compile("USR1") if err != nil { fmt.Printf("regexp.Compile(%q) failed: %v", "Sig USR1", err) return @@ -1342,7 +1342,7 @@ func ExampleGExpect_SendSignal() { } fmt.Println(match) <-r - // Output: Sig USR1 + // Output: Got the USR1 Signal } var tMap map[string][]Batcher diff --git a/testdata/traptest.sh b/testdata/traptest.sh index f5a634a..8e56ebf 100755 --- a/testdata/traptest.sh +++ b/testdata/traptest.sh @@ -1,13 +1,16 @@ #!/bin/bash -FIFOFILE=~/fifo +FIFOFILE=$(mktemp -u) trap 'rm -f $FIFOFILE; echo "Got the INTR Signal"' INT trap 'rm -f $FIFOFILE; echo "Got the QUIT Signal"' QUIT trap 'rm -f $FIFOFILE; echo "Got the USR1 Signal"' USR1 trap 'rm -f $FIFOFILE; echo "Got the HUP Signal"' HUP -[[ -f "$FIFOFILE" ]] && rm -f $FIFOFILE +if [[ -p $FIFOFILE ]] +then + rm -f $FIFOFILE +fi -mkfifo -m 0400 $FIFOFILE || exit +mkfifo -m 0400 $FIFOFILE echo "Waiting for signal" -cat < $FIFOFILE || echo "" +true < $FIFOFILE sleep 10