Source
/* the parent process can either politely ask a child process to finish it's work and perform cleanup */
/*
** Zabbix
** Copyright (C) 2001-2023 Zabbix SIA
**
** This program is free software; you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
** the Free Software Foundation; either version 2 of the License, or
** (at your option) any later version.
**
** 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 General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with this program; if not, write to the Free Software
** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
**/
typedef struct
{
int sig;
int pid;
int uid;
int code;
int status;
}
zbx_siginfo_t;
int sig_parent_pid = -1;
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 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);
siginfo_exit.code = SIG_CHECKED_FIELD(siginfo, si_code);
siginfo_exit.status = SIG_CHECKED_FIELD(siginfo, si_status);
}
void zbx_set_exiting_with_fail(void)
{
sig_exiting = ZBX_EXIT_FAILURE;
}
void zbx_set_exiting_with_succeed(void)