2021-05-18 05:34:52 +08:00
|
|
|
# RUN: env fish_test_helper=%fish_test_helper %fish -C 'set -l fish %fish' %s
|
2019-12-23 20:49:40 +08:00
|
|
|
|
2020-01-14 03:34:22 +08:00
|
|
|
$fish -c 'function main; exit 4; true; end; main'
|
|
|
|
echo $status
|
2019-12-23 20:49:40 +08:00
|
|
|
#CHECK: 4
|
|
|
|
|
2020-01-14 03:34:22 +08:00
|
|
|
$fish -c 'begin; exit 5; true; end'
|
|
|
|
echo $status
|
2019-12-23 20:49:40 +08:00
|
|
|
#CHECK: 5
|
|
|
|
|
2020-05-16 17:20:18 +08:00
|
|
|
$fish -c 'kill -SIGHUP $fish_pid'
|
2020-01-14 03:34:22 +08:00
|
|
|
echo $status
|
2019-12-23 20:49:40 +08:00
|
|
|
#CHECK: 129
|
|
|
|
|
2020-05-16 17:20:18 +08:00
|
|
|
$fish -c 'function main; kill -SIGTERM $fish_pid; true; end; main'
|
2020-01-14 03:34:22 +08:00
|
|
|
echo $status
|
2019-12-23 20:49:40 +08:00
|
|
|
#CHECK: 143
|
2019-06-27 02:07:46 +08:00
|
|
|
|
2019-02-21 09:07:29 +08:00
|
|
|
function alarm --on-signal ALRM
|
2020-01-14 03:34:22 +08:00
|
|
|
echo ALRM received
|
2019-02-21 09:07:29 +08:00
|
|
|
end
|
|
|
|
|
|
|
|
kill -s ALRM $fish_pid
|
2019-06-27 02:07:46 +08:00
|
|
|
# CHECK: ALRM received
|
2019-02-21 09:07:29 +08:00
|
|
|
|
2019-02-24 04:41:01 +08:00
|
|
|
function anychild --on-process-exit 0
|
2020-01-14 03:34:22 +08:00
|
|
|
# Type and exit status
|
|
|
|
echo $argv[1] $argv[3]
|
2019-02-24 04:41:01 +08:00
|
|
|
end
|
|
|
|
|
2019-02-21 13:41:35 +08:00
|
|
|
echo "command false:"
|
2019-02-24 04:41:01 +08:00
|
|
|
command false
|
2019-06-27 02:07:46 +08:00
|
|
|
# CHECK: command false:
|
|
|
|
# CHECK: PROCESS_EXIT 1
|
|
|
|
# CHECK: JOB_EXIT 0
|
|
|
|
|
2019-02-21 13:41:35 +08:00
|
|
|
echo "command true:"
|
2019-02-24 04:41:01 +08:00
|
|
|
command true
|
2019-06-27 02:07:46 +08:00
|
|
|
# CHECK: command true:
|
|
|
|
# CHECK: PROCESS_EXIT 0
|
|
|
|
# CHECK: JOB_EXIT 0
|
|
|
|
|
2019-02-21 13:41:35 +08:00
|
|
|
echo "command false | true:"
|
2019-02-24 04:41:01 +08:00
|
|
|
command false | command true
|
2019-06-27 02:07:46 +08:00
|
|
|
# CHECK: command false | true:
|
|
|
|
# CHECK: PROCESS_EXIT 1
|
|
|
|
# CHECK: PROCESS_EXIT 0
|
|
|
|
# CHECK: JOB_EXIT 0
|
2019-02-21 13:41:35 +08:00
|
|
|
|
2021-05-18 05:34:52 +08:00
|
|
|
# Signals are reported correctly.
|
|
|
|
# SIGKILL $status is 128 + 9 = 137
|
|
|
|
$fish_test_helper sigkill_self
|
|
|
|
# CHECK: PROCESS_EXIT 137
|
|
|
|
# CHECK: JOB_EXIT 0
|
|
|
|
|
2019-02-21 13:41:35 +08:00
|
|
|
function test_blocks
|
2020-01-14 03:34:22 +08:00
|
|
|
block -l
|
2021-05-18 05:34:52 +08:00
|
|
|
command echo "This is the process whose exit event should be blocked"
|
2020-01-14 03:34:22 +08:00
|
|
|
echo "This should come before the event handler"
|
2019-02-21 13:41:35 +08:00
|
|
|
end
|
|
|
|
test_blocks
|
2021-05-18 05:34:52 +08:00
|
|
|
# CHECK: This is the process whose exit event should be blocked
|
2019-06-27 02:07:46 +08:00
|
|
|
# CHECK: This should come before the event handler
|
|
|
|
|
2019-02-21 13:41:35 +08:00
|
|
|
echo "Now event handler should have run"
|
2019-06-27 02:07:46 +08:00
|
|
|
# CHECK: PROCESS_EXIT 0
|
|
|
|
# CHECK: JOB_EXIT 0
|
|
|
|
# CHECK: Now event handler should have run
|
|
|
|
# CHECK: PROCESS_EXIT 0
|