GDAL

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