2021-05-17 14:34:52 -07:00
# RUN: env fish_test_helper=%fish_test_helper %fish -C 'set -l fish %fish' %s
2019-12-23 13:49:40 +01:00
2020-01-13 20:34:22 +01:00
$fish -c 'function main; exit 4; true; end; main'
echo $status
2019-12-23 13:49:40 +01:00
#CHECK: 4
2020-01-13 20:34:22 +01:00
$fish -c 'begin; exit 5; true; end'
echo $status
2019-12-23 13:49:40 +01:00
#CHECK: 5
2020-05-16 11:20:18 +02:00
$fish -c 'kill -SIGHUP $fish_pid'
2020-01-13 20:34:22 +01:00
echo $status
2019-12-23 13:49:40 +01:00
#CHECK: 129
2020-05-16 11:20:18 +02:00
$fish -c 'function main; kill -SIGTERM $fish_pid; true; end; main'
2020-01-13 20:34:22 +01:00
echo $status
2019-12-23 13:49:40 +01:00
#CHECK: 143
2019-06-26 11:07:46 -07:00
2019-02-20 17:07:29 -08:00
function alarm --on-signal ALRM
2020-01-13 20:34:22 +01:00
echo ALRM received
2019-02-20 17:07:29 -08:00
end
kill -s ALRM $fish_pid
2019-06-26 11:07:46 -07:00
# CHECK: ALRM received
2019-02-20 17:07:29 -08:00
2019-02-23 12:41:01 -08:00
function anychild --on-process-exit 0
2021-05-19 11:29:03 -07:00
# Type and exit status
echo $argv [ 1 ] $argv [ 3 ]
end
function anyjob --on-job-exit 0
2020-01-13 20:34:22 +01:00
# Type and exit status
echo $argv [ 1 ] $argv [ 3 ]
2019-02-23 12:41:01 -08:00
end
2019-02-20 21:41:35 -08:00
echo "command false:"
2019-02-23 12:41:01 -08:00
command false
2019-06-26 11:07:46 -07:00
# CHECK: command false:
2021-06-24 18:14:45 +02:00
# (Solaris' false exits with 255, not 1)
# CHECK: PROCESS_EXIT {{1|255}}
2019-06-26 11:07:46 -07:00
# CHECK: JOB_EXIT 0
2019-02-20 21:41:35 -08:00
echo "command true:"
2019-02-23 12:41:01 -08:00
command true
2019-06-26 11:07:46 -07:00
# CHECK: command true:
# CHECK: PROCESS_EXIT 0
# CHECK: JOB_EXIT 0
2019-02-20 21:41:35 -08:00
echo "command false | true:"
2019-02-23 12:41:01 -08:00
command false | command true
2019-06-26 11:07:46 -07:00
# CHECK: command false | true:
2021-06-24 18:14:45 +02:00
# CHECK: PROCESS_EXIT {{1|255}}
2019-06-26 11:07:46 -07:00
# CHECK: PROCESS_EXIT 0
# CHECK: JOB_EXIT 0
2019-02-20 21:41:35 -08:00
2021-05-17 14:34:52 -07: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-20 21:41:35 -08:00
function test_blocks
2020-01-13 20:34:22 +01:00
block -l
2021-05-17 14:34:52 -07:00
command echo "This is the process whose exit event should be blocked"
2020-01-13 20:34:22 +01:00
echo "This should come before the event handler"
2019-02-20 21:41:35 -08:00
end
test_blocks
2021-05-17 14:34:52 -07:00
# CHECK: This is the process whose exit event should be blocked
2019-06-26 11:07:46 -07:00
# CHECK: This should come before the event handler
2019-02-20 21:41:35 -08:00
echo "Now event handler should have run"
2019-06-26 11:07:46 -07:00
# CHECK: PROCESS_EXIT 0
# CHECK: JOB_EXIT 0
# CHECK: Now event handler should have run
# CHECK: PROCESS_EXIT 0