Skip to content

Commit

Permalink
[test/stateful] Test case for running handlers at prompt.
Browse files Browse the repository at this point in the history
This is a reproduction of #1080.
  • Loading branch information
Andy C committed Feb 17, 2022
1 parent cbf3aa4 commit 9e79fc5
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 3 deletions.
22 changes: 20 additions & 2 deletions spec/stateful/signals.py
Expand Up @@ -9,7 +9,7 @@
import time

import harness
from harness import register
from harness import register, expect_prompt


#
Expand Down Expand Up @@ -67,19 +67,37 @@
# 3. trap 'echo X' SIGINT ?


@register()
def sigusr1_trapped_prompt(sh):
'Trapped SIGUSR1 while waiting at prompt (bug 1080)'
expect_prompt(sh)

sh.sendline("trap 'echo zzz-USR1' USR1")
expect_prompt(sh)

sh.kill(signal.SIGUSR1)

# bash and dash need another blank line, mksh doesn't
sh.sendline('')

sh.expect('zzz-USR1')


@register()
def sighup_trapped_wait(sh):
'trapped SIGHUP during wait builtin'

sh.sendline("trap 'echo HUP' HUP")
expect_prompt(sh)
sh.sendline('sleep 1 &')
# TODO: expect something like [1] 24370
sh.sendline('wait')

time.sleep(0.1)

sh.kill(signal.SIGHUP)

sh.expect(r'.*\$') # expect prompt
expect_prompt(sh)

sh.sendline('echo status=$?')
sh.expect('status=129')
Expand Down
2 changes: 1 addition & 1 deletion test/stateful.sh
Expand Up @@ -37,7 +37,7 @@ run() {
readonly FIRST=''

signals-quick() {
spec/stateful/signals.py $FIRST \
spec/stateful/signals.py $FIRST --osh-failures-allowed 1 \
$OSH bash "$@"
}

Expand Down

0 comments on commit 9e79fc5

Please sign in to comment.