Skip to content

Latest commit

 

History

History
112 lines (98 loc) · 3.1 KB

SDL_visualtest_process.h

File metadata and controls

112 lines (98 loc) · 3.1 KB
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
/* See COPYING.txt for the full license governing this code. */
/**
* \file SDL_visualtest_process.h
*
* Provides cross-platfrom process launching and termination functionality.
*/
#include <SDL_platform.h>
#if defined(__WIN32__)
#include <Windows.h>
#include <Shlwapi.h>
#elif defined(__LINUX__)
#include <unistd.h>
#else
#error "Unsupported platform."
#endif
Aug 28, 2017
Aug 28, 2017
19
20
#ifndef SDL_visualtest_process_h_
#define SDL_visualtest_process_h_
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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
/* Set up for C function definitions, even when using C++ */
#ifdef __cplusplus
extern "C" {
#endif
/**
* Struct to store a platform specific handle to a process.
*/
typedef struct SDL_ProcessInfo
{
//#if defined(_WIN32) || defined(__WIN32__)
#if defined(__WIN32__)
PROCESS_INFORMATION pi;
//#elif defined(__linux__)
#elif defined(__LINUX__)
int pid;
#endif
} SDL_ProcessInfo;
/**
* This structure stores the exit status (value returned by main()) and
* whether the process exited sucessfully or not.
*/
typedef struct SDL_ProcessExitStatus
{
int exit_success; /*!< Zero if the process exited successfully */
int exit_status; /*!< The exit status of the process. 8-bit value. */
} SDL_ProcessExitStatus;
/**
* Launches a process with the given commandline arguments.
*
* \param file The path to the executable to be launched.
* \param args The command line arguments to be passed to the process.
* \param pinfo Pointer to an SDL_ProcessInfo object to be populated with
* platform specific information about the launched process.
*
* \return Non-zero on success, zero on failure.
*/
int SDL_LaunchProcess(char* file, char* args, SDL_ProcessInfo* pinfo);
/**
* Checks if a process is running or not.
*
* \param pinfo Pointer to SDL_ProcessInfo object of the process that needs to be
* checked.
*
* \return 1 if the process is still running; zero if it is not and -1 if the
* status could not be retrieved.
*/
int SDL_IsProcessRunning(SDL_ProcessInfo* pinfo);
/**
* Kills a currently running process.
*
* \param pinfo Pointer to a SDL_ProcessInfo object of the process to be terminated.
* \param ps Pointer to a SDL_ProcessExitStatus object which will be populated
* with the exit status.
*
* \return 1 on success, 0 on failure.
*/
int SDL_KillProcess(SDL_ProcessInfo* pinfo, SDL_ProcessExitStatus* ps);
/**
* Cleanly exits the process represented by \c pinfo and stores the exit status
* in the exit status object pointed to by \c ps.
*
* \return 1 on success, 0 on failure.
*/
int SDL_QuitProcess(SDL_ProcessInfo* pinfo, SDL_ProcessExitStatus* ps);
/**
* Gets the exit status of a process. If the exit status is -1, the process is
* still running.
*
* \param pinfo Pointer to a SDL_ProcessInfo object of the process to be checked.
* \param ps Pointer to a SDL_ProcessExitStatus object which will be populated
* with the exit status.
*
* \return 1 on success, 0 on failure.
*/
int SDL_GetProcessExitStatus(SDL_ProcessInfo* pinfo, SDL_ProcessExitStatus* ps);
/* Ends C function definitions when using C++ */
#ifdef __cplusplus
}
#endif
Aug 28, 2017
Aug 28, 2017
110
#endif /* SDL_visualtest_process_h_ */
Aug 28, 2017
Aug 28, 2017
112
/* vi: set ts=4 sw=4 expandtab: */