Source
void zbx_thread_start(ZBX_THREAD_ENTRY_POINTER(handler), zbx_thread_args_t *thread_args, ZBX_THREAD_HANDLE *thread)
/*
** 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 ZBX_THREAD_ENTRY(zbx_win_thread_entry, args)
{
__try
{
zbx_thread_args_t *thread_args = (zbx_thread_args_t *)args;
return thread_args->entry(thread_args);
}
__except(zbx_win_seh_handler(GetExceptionInformation()))
{
zbx_thread_exit(EXIT_SUCCESS);
}
}
void CALLBACK ZBXEndThread(ULONG_PTR dwParam)
{
_endthreadex(SUCCEED);
}
/******************************************************************************
* *
* Purpose: Flush stdout and stderr before forking. *
* *
* Return value: same as system fork() function *
* *
******************************************************************************/
int zbx_fork(void)
{
fflush(stdout);
fflush(stderr);
return fork();
}
/******************************************************************************
* *
* Purpose: fork from master process and set SIGCHLD handler *
* *
* Parameters: pid - [OUT] *
* *
* Comments: use this function only for forks from the main process *
* *
******************************************************************************/
void zbx_child_fork(pid_t *pid)