fork/fish-shell

git clone https://git.julia.blue/fork/fish-shell

ccoVeilleFix typos in commentsb6a1bedab

master
2.0 KiB90 linesraw
1# RUN: env fth=%fish_test_helper %fish %s
2#REQUIRES: command -v %fish_test_helper
3
4set -g SIGUSR1_COUNT 0
5
6function gotsigusr1
7    set -g SIGUSR1_COUNT (math $SIGUSR1_COUNT + 1)
8    echo "Got USR1: $SIGUSR1_COUNT"
9
10end
11
12function handle1 --on-signal SIGUSR1
13    gotsigusr1
14end
15
16function handle_us42 --on-signal SIGUSR2
17end
18
19kill -USR1 $fish_pid
20sleep .1
21#CHECK: Got USR1: 1
22
23kill -USR1 $fish_pid
24sleep .1
25#CHECK: Got USR1: 2
26
27kill -USR2 $fish_pid
28sleep .1
29kill -USR2 $fish_pid
30sleep .1
31
32# Previous signals do not re-trigger handlers.
33functions --erase handle1
34kill -USR1 $fish_pid
35sleep .1
36kill -USR1 $fish_pid
37sleep .1
38
39kill -USR2 $fish_pid
40sleep .1
41
42# Send the signal and immediately define the function; it should not execute.
43kill -USR1 $fish_pid
44function handle1 --on-signal SIGUSR1
45    gotsigusr1
46end
47echo "Hope it did not run"
48#CHECK: Hope it did not run
49
50kill -USR1 $fish_pid
51sleep .1
52#CHECK: Got USR1: 3
53
54# We can trap SIGINT.
55# Trapping it prevents exiting.
56function handle_int --on-signal SIGINT
57    echo Got SIGINT
58end
59kill -INT $fish_pid
60#CHECK: Got SIGINT
61
62# In non-interactive mode, we have historically treated
63# a child process which dies with SIGINT as if we got SIGINT.
64# However in this case we don't execute handlers; we just don't exit.
65$fth sigint_self
66echo "Should not have exited"
67#CHECK: Should not have exited
68
69# If a signal is received while handling a signal, that is deferred until the handler is done.
70set -g INTCOUNT 0
71function handle_int --on-signal SIGINT
72    test $INTCOUNT -gt 2 && return
73    set -g INTCOUNT (math $INTCOUNT + 1)
74    echo "start handle_int $INTCOUNT"
75    sleep .1
76    kill -INT $fish_pid
77    echo "end handle_int $INTCOUNT"
78end
79kill -INT $fish_pid
80# CHECK: start handle_int 1
81# CHECK: end handle_int 1
82# CHECK: start handle_int 2
83# CHECK: end handle_int 2
84# CHECK: start handle_int 3
85# CHECK: end handle_int 3
86
87# Remove our handler and SIGINT ourselves. Now we should exit.
88functions --erase handle_int
89kill -INT $fish_pid
90echo "I should not run"