02/09/2017
Disable Control-C [ CTRL+C ] in linux
Signals are the notification send to a process on the occurrence of an event.
--------------------------------------------------------------------------------------
struct sigaction act;
void sighandler(int signum, siginfo_t *info, void *ptr)
{
printf("Signal From %d\n", signum);
}
int main()
{
printf("UID %lu\n", (unsigned long)getpid());
memset(&act, 0, sizeof(act));
TRY
act.sa_sigaction = sighandler;
act.sa_flags = SA_SIGINFO;
sigaction(SIGINT, &act, NULL);
TRY1
act.sa_handler = SIG_IGN;
sigaction(SIGINT, &act, NULL);
signal(SIGINT, SIG_IGN);
// Waiting for CTRL+C...
sleep(100);
return 0;
}
--------------------------------------------------------------------------------------
Reference:
http://nixcraft.com/shell-scripting/12605-shell-script-disable-ctrl-c-ctrl-z.html