Skip to content

Commit ac6a4c0

Browse files
ayurchenNirbhay Choubey
authored andcommitted
Refs #25 - made sure signals that may be set to ignored in mysqld were set to default in the child process.
1 parent 957ca2f commit ac6a4c0

File tree

1 file changed

+29
-1
lines changed

1 file changed

+29
-1
lines changed

sql/wsrep_utils.cc

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,35 @@ process::process (const char* cmd, const char* type)
150150
goto cleanup_pipe;
151151
}
152152

153-
err_ = posix_spawnattr_setflags (&attr, POSIX_SPAWN_SETSIGDEF |
153+
/* make sure that no signlas are masked in child process */
154+
sigset_t sigmask_empty; sigemptyset(&sigmask_empty);
155+
err_ = posix_spawnattr_setsigmask(&attr, &sigmask_empty);
156+
if (err_)
157+
{
158+
WSREP_ERROR ("posix_spawnattr_setsigmask() failed: %d (%s)",
159+
err_, strerror(err_));
160+
goto cleanup_attr;
161+
}
162+
163+
/* make sure the following signals are not ignored in child process */
164+
sigset_t default_signals; sigemptyset(&default_signals);
165+
sigaddset(&default_signals, SIGHUP);
166+
sigaddset(&default_signals, SIGINT);
167+
sigaddset(&default_signals, SIGQUIT);
168+
sigaddset(&default_signals, SIGPIPE);
169+
sigaddset(&default_signals, SIGTERM);
170+
sigaddset(&default_signals, SIGCHLD);
171+
err_ = posix_spawnattr_setsigdefault(&attr, &default_signals);
172+
if (err_)
173+
{
174+
WSREP_ERROR ("posix_spawnattr_setsigdefault() failed: %d (%s)",
175+
err_, strerror(err_));
176+
goto cleanup_attr;
177+
}
178+
179+
err_ = posix_spawnattr_setflags (&attr, POSIX_SPAWN_SETSIGDEF |
180+
POSIX_SPAWN_SETSIGMASK |
181+
/* start a new process group */ POSIX_SPAWN_SETPGROUP |
154182
POSIX_SPAWN_USEVFORK);
155183
if (err_)
156184
{

0 commit comments

Comments
 (0)