A little background:
mycommand doesn't resend SIGINT when it receives one, and just terminates instead. Because of this,
bash instance running the loop cannot determine that CTRL+C was used to terminate execution, and assumes it was just a keyboard shortcut you issued for
mycommand. Since it would be undesirable to terminate your shell because of a keyboard shortcut (imagine using
vi for instance),
bash just goes on and executes another loop iteration.
The ultimate solution would be to fix
mycommand, so that it kills itself with SIGINT when it receives one, letting
bash know it should stop as well.
void sigint_handler(int sig)
// Execute your normal handler
signal(SIGINT, SIG_DFL); // don't catch the signal anymore
kill(getpid(), SIGINT); // kill itself with the same signal
If you cannot fix
mycommand, you'll have to either close the terminal session, or kill the
bash process which does the looping and the current instance of
mycommand, in that order.