]>
Commit | Line | Data |
---|---|---|
ff28b140 TL |
1 | /* |
2 | * os_win32/popen.h | |
3 | * | |
4 | * Home page of code is: https://www.smartmontools.org | |
5 | * | |
6 | * Copyright (C) 2018 Christian Franke | |
7 | * | |
8 | * SPDX-License-Identifier: GPL-2.0-or-later | |
9 | */ | |
10 | ||
11 | #ifndef POPEN_H | |
12 | #define POPEN_H | |
13 | ||
14 | #define POPEN_H_CVSID "$Id: popen.h 4818 2018-10-17 05:32:17Z chrfranke $" | |
15 | ||
16 | #include <stdio.h> | |
17 | ||
18 | // MinGW <stdio.h> defines these to _popen/_pclose | |
19 | #undef popen | |
20 | #undef pclose | |
21 | ||
22 | #ifdef __cplusplus | |
23 | extern "C" { | |
24 | #endif | |
25 | ||
26 | // popen(3) reimplementation for Windows | |
27 | // | |
28 | // The _popen() from MSVCRT is not useful as it always opens a new | |
29 | // console window if parent process has none. | |
30 | // | |
31 | // Differences to popen(3): | |
32 | // - Only modes "r[bt]" are supported | |
33 | // - stdin and stderr from parent are not inherited to child process | |
34 | // but redirected to null device | |
35 | // - Only one child process can be run at a time | |
36 | ||
37 | FILE * popen(const char * command, const char * mode); | |
38 | ||
39 | int pclose(FILE * f); | |
40 | ||
41 | #ifdef __cplusplus | |
42 | } | |
43 | #endif | |
44 | ||
45 | // wait(3) macros from <sys/wait.h> | |
46 | #ifndef WIFEXITED | |
47 | #define WIFEXITED(status) (((status) & 0xff) == 0x00) | |
48 | #define WIFSIGNALED(status) (((status) & 0xff) != 0x00) | |
49 | #define WIFSTOPPED(status) (0) | |
50 | #define WEXITSTATUS(status) ((status) >> 8) | |
51 | #define WTERMSIG(status) ((status) & 0xff) | |
52 | #define WSTOPSIG(status) (0) | |
53 | #endif // WIFEXITED | |
54 | ||
55 | #endif // POPEN_H |