Materiale rimasto indietro e segnali real time
[gapil.git] / listati / Action.c
diff --git a/listati/Action.c b/listati/Action.c
new file mode 100644 (file)
index 0000000..b119244
--- /dev/null
@@ -0,0 +1,15 @@
+inline SigAction * Action(int signo, SigAction *func) 
+{
+    struct sigaction new_handl, old_handl;
+    new_handl.sa_flags=SA_SIGINFO;           /* we use sa_sigaction handler */
+    new_handl.sa_sigaction = func;           /* set signal handler */
+    /* clear signal mask: no signal blocked during execution of func */
+    if (sigemptyset(&new_handl.sa_mask)!=0){ /* initialize signal set */
+        return NULL;
+    }
+    /* change action for signo signal */
+    if (sigaction(signo, &new_handl, &old_handl)){ 
+        return NULL;
+    }
+    return (old_handl.sa_sigaction);
+}