in reply to Control C; into a running system / exec?

If i kill the process; that does not seem to get handled by trace-cmd in the same way as doing a control c.

Different signals are handled differently. The default sent by kill is SIGTERM whereas ^C is usually bound to SIGINT. Try using kill -INT from the shell and you should get the same effect as ^C.

If you use exec or system to start the subprocess then it will receive the SIGINTs sent by the controlling shell (eg. by entering ^C) and there is nothing special which you need to do in the Perl parent to achieve this behaviour.

To demonstrate, here is inttest.pl followed by inttrap.sh. Make them both executable and then run the former. You will see that your ^C keypresses successfully send SIGINTS to the child shell script.

#!/usr/bin/env perl use strict; use warnings; print "With system ():\n"; system "./inttrap.sh"; print "With exec ():\n"; exec "./inttrap.sh";
#!/bin/bash trap "echo interrupted" 2 for i in {1..5} do sleep 1 echo Waiting $i ... done

🦛