While running a thread program and repeatedly killing the main program using Ctrl + C, i see unexpected results in the program in second run. However, if i let the program run and voluntarily exit, there are no issues.
So, my doubt is, does Ctrl + C, kill threads also along with the main process?
Thanks in advance.
Well, the only thing that
Ctrl + Cdoes is sendingSIGINTto one thread in the process that is not masking the signal. Signals can be handled or ignored.If the program does handle
Ctrl+C, the usual behavior is self-termination, but once again, it could be used for anything else.In your case,
SIGINTis being received by one thread, which probably does kill itself, but does not kill the others.