Why we call the signal function in the start of the linux c program? -
the program simple, have handler function named fintr() , program is: void fintr(); int main() { int i; signal(sigint,fintr); while(1) { printf("*"); } return 0; } void fintr() { printf("signal received"); exit(1); } can put signal(sigint,fintr); @ end of function main() ? , why have put in beginning of main() ? putting @ end means come after while (1) ... loop, no, can't put in end, because never executed. also, pay attention code place inside signal handlers: not safe call printf() inside signal handler.