GDAL

cpl_spawn.h
1/**********************************************************************
2 *
3 * Project: CPL - Common Portability Library
4 * Purpose: Implement CPLSystem().
5 * Author: Even Rouault, <even dot rouault at spatialys.com>
6 *
7 **********************************************************************
8 * Copyright (c) 2013, Even Rouault <even dot rouault at spatialys.com>
9 *
10 * SPDX-License-Identifier: MIT
11 ****************************************************************************/
12
13#ifndef CPL_SPAWN_H_INCLUDED
14#define CPL_SPAWN_H_INCLUDED
15
16#include "cpl_vsi.h"
17
18 CPL_C_START
19
20/* -------------------------------------------------------------------- */
21/* Spawn a process. */
22/* -------------------------------------------------------------------- */
23
24 int CPL_DLL CPLSpawn(const char *const papszArgv[], VSILFILE *fin,
25 VSILFILE *fout, int bDisplayErr);
26
27#ifdef _WIN32
28#include <windows.h>
29 typedef HANDLE CPL_FILE_HANDLE;
30#define CPL_FILE_INVALID_HANDLE CPL_NULLPTR
31 typedef DWORD CPL_PID;
32#else
33#include <sys/types.h>
34 typedef int CPL_FILE_HANDLE;
35#define CPL_FILE_INVALID_HANDLE -1
36 typedef pid_t CPL_PID;
37#endif
38
39 typedef struct _CPLSpawnedProcess CPLSpawnedProcess;
40
41CPLSpawnedProcess CPL_DLL *
42CPLSpawnAsync(int (*pfnMain)(CPL_FILE_HANDLE, CPL_FILE_HANDLE),
43 const char *const papszArgv[], int bCreateInputPipe,
44 int bCreateOutputPipe, int bCreateErrorPipe, char **papszOptions);
45CPL_PID CPL_DLL CPLSpawnAsyncGetChildProcessId(CPLSpawnedProcess *p);
46 int CPL_DLL CPLSpawnAsyncFinish(CPLSpawnedProcess *p, int bWait, int bKill);
47CPL_FILE_HANDLE CPL_DLL CPLSpawnAsyncGetInputFileHandle(CPLSpawnedProcess *p);
48CPL_FILE_HANDLE CPL_DLL CPLSpawnAsyncGetOutputFileHandle(CPLSpawnedProcess *p);
49CPL_FILE_HANDLE CPL_DLL CPLSpawnAsyncGetErrorFileHandle(CPLSpawnedProcess *p);
50 void CPL_DLL CPLSpawnAsyncCloseInputFileHandle(CPLSpawnedProcess *p);
51 void CPL_DLL CPLSpawnAsyncCloseOutputFileHandle(CPLSpawnedProcess *p);
52 void CPL_DLL CPLSpawnAsyncCloseErrorFileHandle(CPLSpawnedProcess *p);
53
54 int CPL_DLL CPLPipeRead(CPL_FILE_HANDLE fin, void *data, int length);
55 int CPL_DLL CPLPipeWrite(CPL_FILE_HANDLE fout, const void *data, int length);
56
57 CPL_C_END
58
59#endif // CPL_SPAWN_H_INCLUDED
CPL_C_END
#define CPL_C_END
Macro to end a block of C symbols.
Definition cpl_port.h:289
CPL_C_START
#define CPL_C_START
Macro to start a block of C symbols.
Definition cpl_port.h:285
cpl_vsi.h
Standard C Covers.
VSIVirtualHandle
Virtual file handle.
Definition cpl_vsi_virtual.h:48