Test at compile time whether siginfo_t is usable for --remote (#119).
This commit is contained in:
@@ -60,6 +60,43 @@ AC_TYPE_SIZE_T
|
||||
AC_TYPE_SSIZE_T
|
||||
AC_TYPE_UID_T
|
||||
|
||||
dnl Check that a signal handler can't see the PID of the sender.
|
||||
AC_MSG_CHECKING([siginfo_t provides a signal sender's PID])
|
||||
AC_RUN_IFELSE(
|
||||
[AC_LANG_PROGRAM([[
|
||||
#include <string.h>
|
||||
#include <signal.h>
|
||||
#include <unistd.h>
|
||||
|
||||
static pid_t signalSender = 0;
|
||||
|
||||
#ifdef SA_SIGINFO
|
||||
static void receiveUSR2( __attribute__((unused))
|
||||
int sig, siginfo_t * info, __attribute__((unused))
|
||||
void *ucontext)
|
||||
{
|
||||
if (NULL != info)
|
||||
signalSender = info->si_pid;
|
||||
}
|
||||
#endif
|
||||
]], [[
|
||||
struct sigaction sa;
|
||||
memset(&sa, 0, sizeof(sa));
|
||||
#ifdef SA_SIGINFO
|
||||
sa.sa_sigaction = receiveUSR2;
|
||||
(void) sigemptyset(&(sa.sa_mask));
|
||||
sa.sa_flags = SA_SIGINFO;
|
||||
(void) sigaction(SIGUSR2, &sa, NULL);
|
||||
raise(SIGUSR2);
|
||||
#endif
|
||||
return signalSender == 0 ? 1 : 0;
|
||||
]])], [
|
||||
AC_MSG_RESULT([yes])
|
||||
AC_DEFINE([SIGINFO_PROVIDES_PID], [1], [Signal handlers can determine the sending PID])
|
||||
], [
|
||||
AC_MSG_RESULT([no])
|
||||
])
|
||||
|
||||
AH_BOTTOM([#include "config-aux.h"])
|
||||
|
||||
AC_ARG_ENABLE([debugging],
|
||||
|
||||
@@ -223,6 +223,9 @@
|
||||
/* Define to the version of this package. */
|
||||
#undef PACKAGE_VERSION
|
||||
|
||||
/* Signal handlers can determine the sending PID */
|
||||
#undef SIGINFO_PROVIDES_PID
|
||||
|
||||
/* Define to 1 if all of the C90 standard headers exist (not just the ones
|
||||
required in a freestanding environment). This macro is provided for
|
||||
backward compatibility; new code need not use it. */
|
||||
|
||||
@@ -154,13 +154,13 @@ struct pvstate_s {
|
||||
struct sigaction old_sigint;
|
||||
struct sigaction old_sighup;
|
||||
struct sigaction old_sigterm;
|
||||
#ifdef SA_SIGINFO
|
||||
#ifdef SIGINFO_PROVIDES_PID
|
||||
struct sigaction old_sigusr2;
|
||||
#endif
|
||||
struct sigaction old_sigalrm;
|
||||
struct timespec tstp_time; /* see pv_sig_tstp() / __cont() */
|
||||
struct timespec toffset; /* total time spent stopped */
|
||||
#ifdef SA_SIGINFO
|
||||
#ifdef SIGINFO_PROVIDES_PID
|
||||
volatile sig_atomic_t rxusr2; /* whether SIGUSR2 was received */
|
||||
volatile pid_t sender; /* PID of sending process for SIGUSR2 */
|
||||
#endif
|
||||
|
||||
+1
-1
@@ -237,7 +237,7 @@ extern off_t pv_calc_total_size(pvstate_t);
|
||||
*/
|
||||
extern void pv_sig_init(pvstate_t);
|
||||
|
||||
#ifdef SA_SIGINFO
|
||||
#ifdef SIGINFO_PROVIDES_PID
|
||||
/*
|
||||
* Return true if SIGUSR2 has been received, and indicate the sender.
|
||||
*/
|
||||
|
||||
+2
-2
@@ -399,11 +399,11 @@ void display_help(void)
|
||||
{ "-U", "--store-and-forward", N_("FILE"),
|
||||
N_("write all input to FILE before writing to output"),
|
||||
{ 0, 0, 0, 0} },
|
||||
#ifdef SA_SIGINFO
|
||||
#ifdef SIGINFO_PROVIDES_PID
|
||||
{ "-R", "--remote", N_("PID"),
|
||||
N_("update settings of process PID"),
|
||||
{ 0, 0, 0, 0} },
|
||||
#endif /* SA_SIGINFO */
|
||||
#endif /* SIGINFO_PROVIDES_PID */
|
||||
{ "", NULL, NULL, NULL, { 0, 0, 0, 0} },
|
||||
{ "-P", "--pidfile", N_("FILE"),
|
||||
N_("save process ID in FILE"),
|
||||
|
||||
+3
-3
@@ -21,7 +21,7 @@
|
||||
#include <sys/time.h>
|
||||
#include <sys/stat.h>
|
||||
|
||||
#ifdef SA_SIGINFO
|
||||
#ifdef SIGINFO_PROVIDES_PID
|
||||
void pv_error(pvstate_t, char *, ...);
|
||||
|
||||
struct remote_msg {
|
||||
@@ -405,10 +405,10 @@ void pv_remote_fini(void)
|
||||
{
|
||||
}
|
||||
|
||||
#else /* !SA_SIGINFO */
|
||||
#else /* !SIGINFO_PROVIDES_PID */
|
||||
|
||||
/*
|
||||
* Dummy stubs for remote control when we don't have SA_SIGINFO.
|
||||
* Dummy stubs for remote control when we don't have SIGINFO_PROVIDES_PID.
|
||||
*/
|
||||
void pv_remote_init(void)
|
||||
{
|
||||
|
||||
+3
-3
@@ -226,7 +226,7 @@ static void pv_sig_term( /*@unused@ */ __attribute__((unused))
|
||||
}
|
||||
|
||||
|
||||
#ifdef SA_SIGINFO
|
||||
#ifdef SIGINFO_PROVIDES_PID
|
||||
/*
|
||||
* Handle a SIGUSR2 by setting a flag to say we received it, after recording
|
||||
* the sending PID.
|
||||
@@ -375,7 +375,7 @@ void pv_sig_init(pvstate_t state)
|
||||
sa.sa_flags = 0;
|
||||
(void) sigaction(SIGTERM, &sa, &(pv_sig_state->signal.old_sigterm));
|
||||
|
||||
#ifdef SA_SIGINFO
|
||||
#ifdef SIGINFO_PROVIDES_PID
|
||||
/*
|
||||
* Handle SIGUSR2 by setting a flag to say the signal has been
|
||||
* received, and storing the sending process's PID.
|
||||
@@ -431,7 +431,7 @@ void pv_sig_fini( /*@unused@ */ __attribute__((unused)) pvstate_t state)
|
||||
(void) sigaction(SIGINT, &(pv_sig_state->signal.old_sigint), NULL);
|
||||
(void) sigaction(SIGHUP, &(pv_sig_state->signal.old_sighup), NULL);
|
||||
(void) sigaction(SIGTERM, &(pv_sig_state->signal.old_sigterm), NULL);
|
||||
#ifdef SA_SIGINFO
|
||||
#ifdef SIGINFO_PROVIDES_PID
|
||||
(void) sigaction(SIGUSR2, &(pv_sig_state->signal.old_sigusr2), NULL);
|
||||
#endif
|
||||
(void) sigaction(SIGALRM, &(pv_sig_state->signal.old_sigalrm), NULL);
|
||||
|
||||
Reference in New Issue
Block a user