added posix signals
This commit is contained in:
19
logging.c
19
logging.c
@@ -361,6 +361,11 @@ static void send_mail()
|
|||||||
char *subject = MAILSUBJECT;
|
char *subject = MAILSUBJECT;
|
||||||
int fd[2];
|
int fd[2];
|
||||||
char buf[MAXLOGLEN + 1024];
|
char buf[MAXLOGLEN + 1024];
|
||||||
|
#ifdef POSIX_SIGNALS
|
||||||
|
struct sigaction action;
|
||||||
|
#endif /* POSIX_SIGNALS */
|
||||||
|
|
||||||
|
(void) bzero((char *)(&action), sizeof(action));
|
||||||
|
|
||||||
/* become root for find_path() */
|
/* become root for find_path() */
|
||||||
be_root();
|
be_root();
|
||||||
@@ -374,7 +379,12 @@ static void send_mail()
|
|||||||
be_user();
|
be_user();
|
||||||
|
|
||||||
/* catch children as they die */
|
/* catch children as they die */
|
||||||
|
#ifdef POSIX_SIGNALS
|
||||||
|
action.sa_handler = reapchild;
|
||||||
|
(void) sigaction(SIGCHLD, &action, NULL);
|
||||||
|
#else
|
||||||
(void) signal(SIGCHLD, reapchild);
|
(void) signal(SIGCHLD, reapchild);
|
||||||
|
#endif /* POSIX_SIGNALS */
|
||||||
|
|
||||||
if (fork())
|
if (fork())
|
||||||
return;
|
return;
|
||||||
@@ -384,9 +394,16 @@ static void send_mail()
|
|||||||
*/
|
*/
|
||||||
be_full_user();
|
be_full_user();
|
||||||
|
|
||||||
|
#ifdef POSIX_SIGNALS
|
||||||
|
action.sa_handler = SIG_IGN;
|
||||||
|
(void) sigaction(SIGHUP, &action, NULL);
|
||||||
|
(void) sigaction(SIGINT, &action, NULL);
|
||||||
|
(void) sigaction(SIGQUIT, &action, NULL);
|
||||||
|
#else
|
||||||
(void) signal(SIGHUP, SIG_IGN);
|
(void) signal(SIGHUP, SIG_IGN);
|
||||||
(void) signal(SIGINT, SIG_IGN);
|
(void) signal(SIGINT, SIG_IGN);
|
||||||
(void) signal(SIGQUIT, SIG_IGN);
|
(void) signal(SIGQUIT, SIG_IGN);
|
||||||
|
#endif /* POSIX_SIGNALS */
|
||||||
|
|
||||||
if (pipe(fd)) {
|
if (pipe(fd)) {
|
||||||
perror("send_mail: pipe");
|
perror("send_mail: pipe");
|
||||||
@@ -430,7 +447,9 @@ static RETSIGTYPE reapchild(sig)
|
|||||||
int sig;
|
int sig;
|
||||||
{
|
{
|
||||||
(void) wait(NULL);
|
(void) wait(NULL);
|
||||||
|
#ifndef POSIX_SIGNALS
|
||||||
(void) signal(SIGCHLD, reapchild);
|
(void) signal(SIGCHLD, reapchild);
|
||||||
|
#endif /* POSIX_SIGNALS */
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user