Skip to content

Commit

Permalink
Adding in SendSignal example.
Browse files Browse the repository at this point in the history
  • Loading branch information
skalle committed Aug 12, 2020
1 parent c6c85d9 commit 7e7e43c
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
4 changes: 2 additions & 2 deletions expect_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -1342,7 +1342,7 @@ func ExampleGExpect_SendSignal() {
}
fmt.Println(match)
<-r
// Output: Sig USR1
// Output: Got the USR1 Signal
}

var tMap map[string][]Batcher
Expand Down
11 changes: 7 additions & 4 deletions testdata/traptest.sh
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 7e7e43c

Please sign in to comment.