#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[])
* 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);
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);
}
/* 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);
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 */