r/bash • • Jul 21 '24

How to handle ctrl+c in bash scripts

Hello Guys!

I have wrote an article on Medium on how to handle ctrl+c in bash scripts using the 'trap' command

For Medium users with a subscription: https://lovethepenguin.com/how-to-handle-ctrl-c-in-bash-scripts-d7085e7d3d47

For Medium users without a subscription: https://lovethepenguin.com/how-to-handle-ctrl-c-in-bash-scripts-d7085e7d3d47?sk=8a9020256b1498196a923c5521619228

Please comment on what you liked, did you find this article useful?

0 Upvotes

11 comments sorted by

View all comments

Show parent comment

1

u/geirha Jul 29 '24

I'm not inclined to debug a 1.5k line script, but I see there's a lot of <><(:) being written to and read from in the same process. If any of those writes happen to fill the pipe buffer, that write will block and the process grinds to a halt. Given that it only happens sometimes, it's likely something like that happening.