Signalhandler

Mal 3 Zeilen um Signale zu verarbeiten. Wichtig ist hierbei das SIGKILL nicht blockierbar ist (SIGTERM übrigens auch nicht ;-) )

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
#include <stdio.h>
#include <signal.h>
#include <stdlib.h>
 
void sig_handler(int signum)
{
	printf("Fetched Strg+cn");
	exit(1);
}
 
int main (int argc, char const *argv[])
{
	/*catch SIGINT (strg+c)*/
	signal(SIGINT,sig_handler);
	while(1);
	return 0;
}

Ähnliche Posts

  1. C Variablen tauschen
  2. C
  3. Impressum / About

23. October 2008 by Robert
Categories: Code | Tags: , | Leave a comment

Leave a Reply

Required fields are marked *