blob: 10967a8b18ad0a4634caabc898f341b952428477 (
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
|
/***************************************************************************/
/* 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_launch_external_test_process( INT* exit_status_ptr, CHAR* argv[])
{
/* Validate pointers. */
return_value_if_fail( NULL != exit_status_ptr, TLS_TEST_INVALID_POINTER);
INT status, process_status;
pid_t pid;
pid = fork();
return_value_if_fail( -1 != pid, TLS_TEST_SYSTEM_CALL_FAILED);
if ( 0 == pid)
{
/* Child process. */
/* Enable the timer in child process which will not be inherited by forked child process. */
INT exec_status = execvp( argv[0], argv);
return_value_if_fail( -1 != exec_status, TLS_TEST_SYSTEM_CALL_FAILED);
}
else
{
/* Parent process. */
status = waitpid( pid, &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;
}
}
|