The goal is to block an Apache httpd process until either 15 seconds or another process issues a SIGUSR1 signal. The process id of the blocked process is stored in a db that other processes can access. I am using pselect()/kill() functions to attempt do this.
From my logs, I know the kill(pid, SIGUSR1)
is executed before the 15s timeout and is using the correct pid. However, the pselect()
always times out (despite sending SIGUSR1).
Is this simply not possible in the Apache HTTP server architecture?
Here are the code snippets of the blocked process, and the process attempting to unblock it.
savePid(getpid());
struct timespec t = {15, 0};
sigset_t mask;
sigemptyset(&mask);
sigaddset(&mask, SIGUSR1);
res = pselect(0, NULL, NULL, NULL, &t, &mask);
if (res == 0) {
/*
* timeout
*/
...
} else {
/*
* interrupted
*/
...
}
Another process has decided to "unblock" the process blocked in the pselect, and issues a
pid = getStoredPid();
kill(pid, SIGUSR1)
Apacher Server Information:
Server version: Apache/2.4.41 (Unix)
Server built: Aug 3 2020 16:34:41
Server's Module Magic Number: 20120211:88
Server loaded: APR 1.7.0, APR-UTIL 1.6.1
Compiled using: APR 1.7.0, APR-UTIL 1.6.1
Architecture: 64-bit
Server MPM: prefork
threaded: no
forked: yes (variable process count)
Server compiled with....
-D APR_HAS_SENDFILE
-D APR_HAS_MMAP
-D APR_HAVE_IPV6 (IPv4-mapped addresses enabled)
-D APR_USE_PROC_PTHREAD_SERIALIZE
-D APR_USE_PTHREAD_SERIALIZE
-D SINGLE_LISTEN_UNSERIALIZED_ACCEPT
-D APR_HAS_OTHER_CHILD
-D AP_HAVE_RELIABLE_PIPED_LOGS
-D DYNAMIC_MODULE_LIMIT=256
-D HTTPD_ROOT="/usr"
-D SUEXEC_BIN="no"
-D DEFAULT_PIDLOG="/var/logs/httpd.pid"
-D DEFAULT_SCOREBOARD="logs/apache_runtime_status"
-D DEFAULT_ERRORLOG="logs/error_log"
-D AP_TYPES_CONFIG_FILE="/etc/apache/mime.types"
-D SERVER_CONFIG_FILE="/etc/apache/httpd.conf"