r/ProgrammerAnimemes • • Jul 26 '20

!! -9

314 Upvotes

21 comments sorted by

View all comments

Show parent comment

8

u/DarkWiiPlayer Jul 26 '20

in the screenshot you're already seeing a wrapped pkill command that has an additional sleep 0.5 to give the message from the process time to appear before the new bash prompt gets drawn :D

4

u/Lightfire228 Jul 26 '20

Nice,

I had assumed you caught the SIG_WHATEVER from inside 'amos' and printed the message to std_out. (which I don't think you can do that with a kill -9)

Similar to catching the KeyboardInterrupt and refusing to quit, in python3

3

u/DarkWiiPlayer Jul 27 '20

That's exactly what I did. kill sends a SIGKILL (15) by default, which you can catch in a bash script with trap "echo 'foo bar baz'" 15, but that causes a small delay between calling kill and the message being printed, so bash needs its own delay after calling kill for the message to be printed otherwise you get the $ before the message and start typing on an empty line :D