~ubuntu-branches/ubuntu/trusty/keepalived/trusty

« back to all changes in this revision

Viewing changes to keepalived/core/daemon.c

  • Committer: Bazaar Package Importer
  • Author(s): Alexander Wirt
  • Date: 2005-04-29 23:22:40 UTC
  • mfrom: (1.1.1 upstream) (2.1.1 hoary)
  • Revision ID: james.westby@ubuntu.com-20050429232240-a8m3jtpi3cvuyyy2
Tags: 1.1.11-3
Added a warning about sarge kernels to README.Debian and 
the package description 

Show diffs side-by-side

added added

removed removed

Lines of Context:
5
5
 *
6
6
 * Part:        Main program structure.
7
7
 *
8
 
 * Version:     $Id: main.c,v 1.1.7 2004/04/04 23:28:05 acassen Exp $
 
8
 * Version:     $Id: main.c,v 1.1.11 2005/03/01 01:22:13 acassen Exp $
9
9
 *
10
10
 * Author:      Alexandre Cassen, <acassen@linux-vs.org>
11
11
 *
19
19
 *              as published by the Free Software Foundation; either version
20
20
 *              2 of the License, or (at your option) any later version.
21
21
 *
22
 
 * Copyright (C) 2001-2004 Alexandre Cassen, <acassen@linux-vs.org>
 
22
 * Copyright (C) 2001-2005 Alexandre Cassen, <acassen@linux-vs.org>
23
23
 */
24
24
 
25
25
#include <syslog.h>
75
75
        umask(0);
76
76
        return 0;
77
77
}
78
 
 
79
 
/*
80
 
 * SIGCHLD handler. Reap all zombie child.
81
 
 * WNOHANG prevent against parent process get
82
 
 * stuck waiting child termination.
83
 
 */
84
 
void
85
 
dummy_handler(int sig)
86
 
{
87
 
        /* Dummy */
88
 
}
89
 
 
90
 
void
91
 
signal_noignore_sigchld(void)
92
 
{
93
 
        struct sigaction sa;
94
 
        sigset_t mask;
95
 
 
96
 
        /* Need to remove the NOCHLD flag */
97
 
        sigemptyset(&mask);
98
 
        sa.sa_handler = dummy_handler;
99
 
        sa.sa_mask = mask;
100
 
        sa.sa_flags = 0;
101
 
 
102
 
        sigaction(SIGCHLD, &sa, NULL);
103
 
 
104
 
        /* Block SIGCHLD so that we only receive it
105
 
         * when required (ie when its unblocked in the
106
 
         * select loop)
107
 
         */
108
 
        sigaddset(&mask, SIGCHLD);
109
 
        sigprocmask(SIG_BLOCK, &mask, NULL);
110
 
}
111
 
 
112
 
/* Signal wrapper */
113
 
void *
114
 
signal_set(int signo, void (*func) (int))
115
 
{
116
 
        int ret;
117
 
        struct sigaction sig;
118
 
        struct sigaction osig;
119
 
 
120
 
        sig.sa_handler = func;
121
 
        sigemptyset(&sig.sa_mask);
122
 
        sig.sa_flags = 0;
123
 
#ifdef SA_RESTART
124
 
        sig.sa_flags |= SA_RESTART;
125
 
#endif                          /* SA_RESTART */
126
 
 
127
 
        ret = sigaction(signo, &sig, &osig);
128
 
 
129
 
        if (ret < 0)
130
 
                return (SIG_ERR);
131
 
        else
132
 
                return (osig.sa_handler);
133
 
}
134
 
 
135
 
/* Signal remove */
136
 
void *
137
 
signal_ignore(int signo)
138
 
{
139
 
        return signal_set(signo, SIG_IGN);
140
 
}