blob: b825d56350b2ea72d3c37373c22c0085b6571e41 (
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
|
FILE *
popen(const char *command, const char *mode) {
sigset_t saved;
FILE *rc = NULL;
if (!pseudo_check_wrappers() || !real_popen) {
/* rc was initialized to the "failure" value */
pseudo_enosys("popen");
return rc;
}
pseudo_debug(PDBGF_WRAPPER, "called: popen\n");
pseudo_sigblock(&saved);
if (pseudo_getlock()) {
errno = EBUSY;
sigprocmask(SIG_SETMASK, &saved, NULL);
return NULL;
}
int save_errno;
/* exec*() use this to restore the sig mask */
pseudo_saved_sigmask = saved;
rc = wrap_popen(command, mode);
save_errno = errno;
pseudo_droplock();
sigprocmask(SIG_SETMASK, &saved, NULL);
#if 0
/* This can cause hangs on some recentish systems which use locale
* stuff for strerror...
*/
pseudo_debug(PDBGF_WRAPPER, "completed: popen (maybe: %s)\n", strerror(save_errno));
#endif
pseudo_debug(PDBGF_WRAPPER, "completed: popen (errno: %d)\n", save_errno);
errno = save_errno;
return rc;
}
static FILE *
wrap_popen(const char *command, const char *mode) {
FILE *rc = NULL;
#include "guts/popen.c"
return rc;
}
|