Source
/* the parent process can either politely ask a child process to finish it's work and perform cleanup */
/*
** Copyright (C) 2001-2025 Zabbix SIA
**
** This program is free software: you can redistribute it and/or modify it under the terms of
** the GNU Affero General Public License as published by the Free Software Foundation, version 3.
**
** This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
** without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
** See the GNU Affero General Public License for more details.
**
** You should have received a copy of the GNU Affero General Public License along with this program.
** If not, see <https://www.gnu.org/licenses/>.
**/
static int sig_parent_pid = -1;
static const pid_t *child_pids = NULL;
static size_t child_pid_count = 0;
void set_sig_parent_pid(int in)
{
sig_parent_pid = in;
}
int get_sig_parent_pid(void)
{
return sig_parent_pid;
}
typedef struct
{
int sig;
int pid;
int uid;
int code;
int status;
}
zbx_siginfo_t;
static volatile sig_atomic_t sig_exiting;
static volatile sig_atomic_t sig_exit_on_terminate = 1;
static zbx_on_exit_t zbx_on_exit_cb = NULL;
static void *zbx_on_exit_args = NULL;
static zbx_siginfo_t siginfo_exit = {-1, -1, -1, -1, -1};
static void set_siginfo_exit(int sig, siginfo_t *siginfo)
{
siginfo_exit.sig = sig;
siginfo_exit.pid = SIG_CHECKED_FIELD(siginfo, si_pid);
siginfo_exit.uid = SIG_CHECKED_FIELD(siginfo, si_uid);