0

I have a script, script-A, which runs script-B. When run under the terminal, it terminates as expected from Ctrl-C, but when run via ssh it continues to silently run after Ctrl-C even though ssh disconnects as usual.

~/bin/script-A.sh:

#!/usr/bin/env bash # This script will create 15 empty files in your ~/log dir. # If you run it via `ssh localhost ~/bin/script-A.sh`, # it will keep doing so even after having seemingly exited! for i in $(seq 1 15); do touch ~/log/$(date '+%Y-%m-%d--%H-%M-%S')__still_here.log timeout --foreground 1000 ~/bin/script-B.sh # echo 'here' # if uncommented, this kills the script!! done 

~/bin/script-B.sh:

#!/usr/bin/env bash # This script allows `script-A.sh` to keep running after Ctrl-C! function retry { ${@} echo "here" # this is needed to repro the behavior!! } retry timeout 1 sleep 1000 

I can reproduce this behavior on both Linux and macOS, so it seems to be intended behavior. But what precise mechanism could be causing it?

2
  • 1
    You don't use ssh -t for this, right? Commented May 10, 2023 at 3:53
  • Interesting, ssh -t shows that it is still running after Ctrl-C. Commented May 10, 2023 at 4:06

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.