fish-shell/tests/checks/signal.fish

76 lines
1.6 KiB
Fish
Raw Normal View History

# RUN: env fish_test_helper=%fish_test_helper %fish -C 'set -l fish %fish' %s
$fish -c 'function main; exit 4; true; end; main'
echo $status
#CHECK: 4
$fish -c 'begin; exit 5; true; end'
echo $status
#CHECK: 5
$fish -c 'kill -SIGHUP $fish_pid'
echo $status
#CHECK: 129
$fish -c 'function main; kill -SIGTERM $fish_pid; true; end; main'
echo $status
#CHECK: 143
2019-06-26 18:07:46 +00:00
2019-02-21 01:07:29 +00:00
function alarm --on-signal ALRM
echo ALRM received
2019-02-21 01:07:29 +00:00
end
kill -s ALRM $fish_pid
2019-06-26 18:07:46 +00:00
# CHECK: ALRM received
2019-02-21 01:07:29 +00:00
2019-02-23 20:41:01 +00:00
function anychild --on-process-exit 0
# Type and exit status
echo $argv[1] $argv[3]
end
function anyjob --on-job-exit 0
# Type and exit status
echo $argv[1] $argv[3]
2019-02-23 20:41:01 +00:00
end
echo "command false:"
2019-02-23 20:41:01 +00:00
command false
2019-06-26 18:07:46 +00:00
# CHECK: command false:
# (Solaris' false exits with 255, not 1)
# CHECK: PROCESS_EXIT {{1|255}}
2019-06-26 18:07:46 +00:00
# CHECK: JOB_EXIT 0
echo "command true:"
2019-02-23 20:41:01 +00:00
command true
2019-06-26 18:07:46 +00:00
# CHECK: command true:
# CHECK: PROCESS_EXIT 0
# CHECK: JOB_EXIT 0
echo "command false | true:"
2019-02-23 20:41:01 +00:00
command false | command true
2019-06-26 18:07:46 +00:00
# CHECK: command false | true:
# CHECK: PROCESS_EXIT {{1|255}}
2019-06-26 18:07:46 +00:00
# CHECK: PROCESS_EXIT 0
# CHECK: JOB_EXIT 0
# Signals are reported correctly.
# SIGKILL $status is 128 + 9 = 137
$fish_test_helper sigkill_self
# CHECK: PROCESS_EXIT 137
# CHECK: JOB_EXIT 0
function test_blocks
block -l
command echo "This is the process whose exit event should be blocked"
echo "This should come before the event handler"
end
test_blocks
# CHECK: This is the process whose exit event should be blocked
2019-06-26 18:07:46 +00:00
# CHECK: This should come before the event handler
echo "Now event handler should have run"
2019-06-26 18:07:46 +00:00
# CHECK: PROCESS_EXIT 0
# CHECK: JOB_EXIT 0
# CHECK: Now event handler should have run
# CHECK: PROCESS_EXIT 0