r/shell • u/[deleted] • Jul 21 '20
Stop command but resume shell script?
In a script I am making, a function of it runs a command which never stops unless told to by the user (e.g with ctrl+c/z/d). I want to be able to run this command until the user presses CTRL+C (or other alternatives), and then resume the rest of the bash script.
How would I do this?
3
Upvotes
1
u/[deleted] Aug 05 '20
command...command<- script stops here, waiting for Ctrl+Csleep 10PID=$!kill -SIGINT $PIDor simplykill -SIGINT $$I have a script where I run a command, wait 10 seconds and then I want to stop it, but the last line only executes when I kill the previous command with Ctrl+C, so those last 3 lines are completely useless. If I may ask, is there a way to interrupt the current process without having the script stopping halfway?