When cross-compiling, we cannot run a test program to check whether a siginfo_t provides the signal sender PID, so we fall back to assuming that it does, and also check that SA_SIGINFO is declared so compilation will not fail on systems without it (#120).
This commit is contained in:
+6
-1
@@ -40,6 +40,7 @@ AC_CHECK_HEADERS([sys/ioctl.h])
|
||||
AC_CHECK_HEADERS([libintl.h locale.h])
|
||||
AC_CHECK_HEADERS([sys/sysmacros.h])
|
||||
AC_CHECK_MEMBERS([struct stat.st_blksize])
|
||||
AC_CHECK_DECLS([SA_SIGINFO], [], [], [[#include <signal.h>]])
|
||||
|
||||
AC_SEARCH_LIBS([sqrtl],[m])
|
||||
AC_CHECK_HEADERS([math.h])
|
||||
@@ -98,7 +99,11 @@ AC_MSG_RESULT([yes])
|
||||
AC_DEFINE([SIGINFO_PROVIDES_PID], [1], [Signal handlers can determine the sending PID])
|
||||
], [
|
||||
AC_MSG_RESULT([no])
|
||||
])
|
||||
], [
|
||||
AC_MSG_RESULT([cannot check, assuming yes])
|
||||
AC_DEFINE([SIGINFO_PROVIDES_PID], [1], [Signal handlers can determine the sending PID])
|
||||
]
|
||||
)
|
||||
|
||||
AH_BOTTOM([#include "config-aux.h"])
|
||||
|
||||
|
||||
@@ -43,3 +43,11 @@ typedef bool _Bool;
|
||||
# define true 1
|
||||
# define __bool_true_false_are_defined 1
|
||||
#endif
|
||||
|
||||
/* Whether "--remote" should be available. */
|
||||
#undef PV_REMOTE_CONTROL
|
||||
#if HAVE_DECL_SA_SIGINFO
|
||||
# if SIGINFO_PROVIDES_PID
|
||||
#define PV_REMOTE_CONTROL 1
|
||||
# endif
|
||||
#endif
|
||||
|
||||
@@ -28,6 +28,10 @@
|
||||
*/
|
||||
#undef HAVE_DCGETTEXT
|
||||
|
||||
/* Define to 1 if you have the declaration of `SA_SIGINFO', and to 0 if you
|
||||
don't. */
|
||||
#undef HAVE_DECL_SA_SIGINFO
|
||||
|
||||
/* Define to 1 if you have the `dup2' function. */
|
||||
#undef HAVE_DUP2
|
||||
|
||||
|
||||
@@ -159,13 +159,13 @@ struct pvstate_s {
|
||||
struct sigaction old_sigint;
|
||||
struct sigaction old_sighup;
|
||||
struct sigaction old_sigterm;
|
||||
#ifdef SIGINFO_PROVIDES_PID
|
||||
#ifdef PV_REMOTE_CONTROL
|
||||
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 SIGINFO_PROVIDES_PID
|
||||
#ifdef PV_REMOTE_CONTROL
|
||||
volatile sig_atomic_t rxusr2; /* whether SIGUSR2 was received */
|
||||
volatile pid_t sender; /* PID of sending process for SIGUSR2 */
|
||||
#endif
|
||||
|
||||
+1
-1
@@ -238,7 +238,7 @@ extern off_t pv_calc_total_size(pvstate_t);
|
||||
*/
|
||||
extern void pv_sig_init(pvstate_t);
|
||||
|
||||
#ifdef SIGINFO_PROVIDES_PID
|
||||
#ifdef PV_REMOTE_CONTROL
|
||||
/*
|
||||
* Return true if SIGUSR2 has been received, and indicate the sender.
|
||||
*/
|
||||
|
||||
+2
-2
@@ -405,11 +405,11 @@ void display_help(void)
|
||||
{ "-d", "--watchfd", N_("PID[:FD]"),
|
||||
N_("watch file FD opened by process PID"),
|
||||
{ 0, 0, 0, 0} },
|
||||
#ifdef SIGINFO_PROVIDES_PID
|
||||
#ifdef PV_REMOTE_CONTROL
|
||||
{ "-R", "--remote", N_("PID"),
|
||||
N_("update settings of process PID"),
|
||||
{ 0, 0, 0, 0} },
|
||||
#endif /* SIGINFO_PROVIDES_PID */
|
||||
#endif /* PV_REMOTE_CONTROL */
|
||||
{ "", 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 SIGINFO_PROVIDES_PID
|
||||
#ifdef PV_REMOTE_CONTROL
|
||||
void pv_error(pvstate_t, char *, ...);
|
||||
|
||||
struct remote_msg {
|
||||
@@ -407,10 +407,10 @@ void pv_remote_fini(void)
|
||||
{
|
||||
}
|
||||
|
||||
#else /* !SIGINFO_PROVIDES_PID */
|
||||
#else /* !PV_REMOTE_CONTROL */
|
||||
|
||||
/*
|
||||
* Dummy stubs for remote control when we don't have SIGINFO_PROVIDES_PID.
|
||||
* Dummy stubs for remote control when we don't have PV_REMOTE_CONTROL.
|
||||
*/
|
||||
void pv_remote_init(void)
|
||||
{
|
||||
|
||||
+3
-3
@@ -226,7 +226,7 @@ static void pv_sig_term( /*@unused@ */ __attribute__((unused))
|
||||
}
|
||||
|
||||
|
||||
#ifdef SIGINFO_PROVIDES_PID
|
||||
#ifdef PV_REMOTE_CONTROL
|
||||
/*
|
||||
* 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 SIGINFO_PROVIDES_PID
|
||||
#ifdef PV_REMOTE_CONTROL
|
||||
/*
|
||||
* 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 SIGINFO_PROVIDES_PID
|
||||
#ifdef PV_REMOTE_CONTROL
|
||||
(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