summaryrefslogtreecommitdiff
path: root/test/regression/interoperability_test/test_frame/tls_test_wait_external_test_process.c
blob: 8aea164698cac8e6cc04b1d7411daf33b715f5f6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
/***************************************************************************/
/* Copyright (c) 2024 Microsoft Corporation                                */
/* Copyright (c) 2026 Eclipse ThreadX contributors                         */
/*                                                                         */
/* This program and the accompanying materials are made available under    */
/* the terms of the MIT License which is available at                      */
/* https://opensource.org/licenses/MIT.                                    */
/*                                                                         */
/* SPDX-License-Identifier: MIT                                            */
/***************************************************************************/

#include "tls_test_frame.h"

/* Call external program without output redirecting. */
INT tls_test_wait_external_test_process( TLS_TEST_EXTERNAL_TEST_PROCESS* test_process_ptr, INT* exit_status_ptr)
{
    /* Validate pointers. */
    return_value_if_fail( NULL != test_process_ptr, TLS_TEST_INVALID_POINTER);
    return_value_if_fail( NULL != exit_status_ptr, TLS_TEST_INVALID_POINTER);

    INT process_status = 0, status;
    status = waitpid( test_process_ptr -> tls_test_external_test_process_id, &process_status, 0);
    return_value_if_fail( -1 != status, TLS_TEST_SYSTEM_CALL_FAILED);

    *exit_status_ptr = 0;
    if ( WIFEXITED( process_status))
    {
        *exit_status_ptr = WEXITSTATUS( process_status);
    }
    else if ( WIFSIGNALED( process_status))
    {
        *exit_status_ptr = -WTERMSIG( process_status);
    }
    return TLS_TEST_SUCCESS;
}