Quote:
why the second printf in main is being executed after pressing CTRL \ . the iiiiiiiis is being printed only after i m pressing CTRL \ ,,
Please do use tags, else it would be difficult to read your code.
Output that you get is logical.
"use CTRL \\ for exiting" ==> would be immediately printed once it encounters a "\n".
Yes, there is a "\n" in the printf, so its getting printed.
The next statement, "iiiiiiiiiiiiiis" now will be in the stdout buffer and would remain to be there, unless the buffer is full and the kernel explicitly flushes it out or there is a "\n" in the printf.
Neither of the conditions are satisfied here,
so when CTRL + \ is given to the running binary, the function 'suicide' is executed which prints the statement in the printf block and it has got a "\n".
So, the new statement - " hii u r in suicide ", is appended in the stdout buffer along with "iiiiiiiiiiiiiiiiis" and gets printed.