Source
/* restore original stdout and stderr, because we don't want our output to be confused with script's output */
/*
** 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/>.
**/
/* the size of temporary buffer used to read from output stream */
/******************************************************************************
* *
* Purpose: considers a difference between times in milliseconds *
* *
* Parameters: time1 - [IN] first time point *
* time2 - [IN] second time point *
* *
* Return value: difference between times in milliseconds *
* *
******************************************************************************/
static int zbx_get_timediff_ms(struct _timeb *time1, struct _timeb *time2)
{
int ms;
ms = (int)(time2->time - time1->time) * 1000;
ms += time2->millitm - time1->millitm;
if (0 > ms)
ms = 0;
return ms;
}
/******************************************************************************
* *
* Purpose: read data from pipe *
* *
* Parameters: hRead - [IN] a handle to the device *
* buf - [IN/OUT] a pointer to the buffer *
* buf_size - [IN] buffer size *
* offset - [IN/OUT] current position in the buffer *
* timeout_ms - [IN] timeout in milliseconds *
* *
* Return value: SUCCEED, FAIL or TIMEOUT_ERROR if timeout reached *
* *
******************************************************************************/
static int zbx_read_from_pipe(HANDLE hRead, char **buf, size_t *buf_size, size_t *offset, int timeout_ms)