Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Control+C does not work in timeout-child process in bash

Here goes a simple two-level script:

test.sh

#!/bin/bash
timeout 100 ./test-inner.sh

test-inner.sh

#!/bin/bash
sleep 100000

And, executing

./test.sh

If I try to kill test.sh process by Control+C, it does not work. Could you help me out of here?

like image 552
jaeyong Avatar asked Feb 24 '26 10:02

jaeyong


1 Answers

Timeout program might had signal handler which could be configured by user with --foreground option. As you can see at it manual page:

   --foreground

          When not running timeout directly from  a  shell  prompt,  allow
          COMMAND  to  read from the TTY and receive TTY signals.  In this
          mode, children of COMMAND will not be timed out.
like image 51
Amir Naghizadeh Avatar answered Feb 27 '26 01:02

Amir Naghizadeh



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!