From: Simone Piccardi Date: Fri, 20 May 2011 17:57:22 +0000 (+0000) Subject: Modifica da uso. X-Git-Url: https://gapil.gnulinux.it/gitweb/?a=commitdiff_plain;h=affaf73ebd2ee75be4a08945d1f8e797128eb398;p=gapil.git Modifica da uso. --- diff --git a/sources/testsignalcgi.c b/sources/testsignalcgi.c index 5692c83..b021b2f 100644 --- a/sources/testsignalcgi.c +++ b/sources/testsignalcgi.c @@ -45,7 +45,6 @@ typedef void SigFunc(int, siginfo_t *, void *); SigFunc * Signal(int signo, SigFunc *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,7 +92,6 @@ 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)); }