Sistemati alcuni nomi, l'inserimento dell'indice analitico e della
[gapil.git] / sources / testsignalcgi.c
index 5692c83f59676d1e28f165e09fffca2dc725d00b..010cef54d87e0a4bcd1325afbde4a1a2959c2a1c 100644 (file)
 #include <time.h>
 
 void sig_hand(int, siginfo_t *, void *);
-typedef void SigFunc(int, siginfo_t *, void *);
+typedef void SigAction(int, siginfo_t *, void *);
 /* Function Signal: Initialize a signal handler. See SigHand.c */
-SigFunc * Signal(int signo, SigFunc *func);
+SigAction * Signal(int signo, SigAction *func);
 
 FILE * file;
-time_t t;
 
 /* Program begin */
 int main(int argc, char *argv[], char *envp[])
@@ -54,11 +53,12 @@ int main(int argc, char *argv[], char *envp[])
  * Variables definition         
  */
     char content[]="Content-type: text/html\n\n";
+    time_t t;
     int i;
     struct sigaction new_handl, old_handl;
     /* write mime-type to stdout */ 
     write(STDOUT_FILENO, content, strlen(content));
-    file = fopen("/tmp/testcgi.out","w+");
+    file = fopen("/tmp/testsignalcgi.out","w+");
     Signal(SIGPIPE,sig_hand);
     Signal(SIGQUIT,sig_hand);
     Signal(SIGTERM,sig_hand);
@@ -67,12 +67,10 @@ int main(int argc, char *argv[], char *envp[])
     Signal(SIGUSR1,sig_hand);
     Signal(SIGUSR2,sig_hand);
     Signal(SIGIO,sig_hand);
-    Signal(SIGIO,sig_hand);
     Signal(SIGURG,sig_hand);
     Signal(SIGABRT,sig_hand);
     pause();
     t = time(NULL);
-    fprintf(stdout, "Exit time: %s", ctime(&t));
     fprintf(file, "Exit time: %s", ctime(&t));
     exit(0);
 }
@@ -84,10 +82,9 @@ void sig_hand(int sig, siginfo_t * siginfo, void *ptr) {
 
     /* just return to interrupt sigsuspend */
     pid_t pid;
+    time_t t;
     t = time(NULL);
-    fprintf(stdout, "Received time: %s", ctime(&t));
     fprintf(file, "Received time: %s", ctime(&t));
-    fprintf(stdout, "Signal is: %i\n", sig);
     pid=getpid();
     fprintf(file, "My pid is: %i, sending pid %i, uid %i\n", 
            pid,siginfo->si_pid,siginfo->si_uid);
@@ -95,11 +92,10 @@ void sig_hand(int sig, siginfo_t * siginfo, void *ptr) {
            sig,siginfo->si_signo,siginfo->si_errno,siginfo->si_code);
     sleep(1);
     t = time(NULL);
-    fprintf(stdout, "Printed time: %s", ctime(&t));
     fprintf(file, "Printed time: %s", ctime(&t));
 }
 
-inline SigFunc * Signal(int signo, SigFunc *func) 
+inline SigAction * Signal(int signo, SigAction *func) 
 {
     struct sigaction new_handl, old_handl;
     new_handl.sa_sigaction = func;             /* set signal handler */