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
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
|
diff -ur Libc-1272.200.26/stdlib/FreeBSD/system.c Libc-1272.200.26+iPhone/stdlib/FreeBSD/system.c
--- Libc-1272.200.26/stdlib/FreeBSD/system.c 2018-03-22 07:37:55.000000000 -1000
+++ Libc-1272.200.26+iPhone/stdlib/FreeBSD/system.c 2019-05-01 23:27:20.000000000 -1000
@@ -57,20 +57,14 @@
#if __DARWIN_UNIX03
#include <pthread.h>
-#if !(TARGET_OS_IPHONE && (TARGET_OS_SIMULATOR || !TARGET_OS_IOS))
static pthread_mutex_t __systemfn_mutex = PTHREAD_MUTEX_INITIALIZER;
-#endif
extern int __unix_conforming;
#endif /* __DARWIN_UNIX03 */
int
-__system(command)
+system(command)
const char *command;
{
-#if TARGET_OS_IPHONE && (TARGET_OS_SIMULATOR || !TARGET_OS_IOS)
- // Don't abort() on iOS for now
- LIBC_ABORT("system() is not supported on this platform.");
-#else
pid_t pid, savedpid;
int pstat, err;
struct sigaction ign, intact, quitact;
@@ -88,14 +82,10 @@
#endif /* __DARWIN_UNIX03 */
if (!command) { /* just checking... */
-#if TARGET_OS_IPHONE
- return(0);
-#else
if (access(_PATH_BSHELL, F_OK) == -1) /* if no sh or no access */
return(0);
else
return(1);
-#endif
}
if ((err = posix_spawnattr_init(&attr)) != 0) {
@@ -114,19 +104,19 @@
ign.sa_handler = SIG_IGN;
(void)sigemptyset(&ign.sa_mask);
ign.sa_flags = 0;
- (void)_sigaction(SIGINT, &ign, &intact);
+ (void)sigaction(SIGINT, &ign, &intact);
if (intact.sa_handler != SIG_IGN) {
sigaddset(&defaultsig, SIGINT);
flags |= POSIX_SPAWN_SETSIGDEF;
}
- (void)_sigaction(SIGQUIT, &ign, &quitact);
+ (void)sigaction(SIGQUIT, &ign, &quitact);
if (quitact.sa_handler != SIG_IGN) {
sigaddset(&defaultsig, SIGQUIT);
flags |= POSIX_SPAWN_SETSIGDEF;
}
(void)sigemptyset(&newsigblock);
(void)sigaddset(&newsigblock, SIGCHLD);
- (void)_sigprocmask(SIG_BLOCK, &newsigblock, &oldsigblock);
+ (void)sigprocmask(SIG_BLOCK, &newsigblock, &oldsigblock);
(void)posix_spawnattr_setsigmask(&attr, &oldsigblock);
if (flags & POSIX_SPAWN_SETSIGDEF) {
(void)posix_spawnattr_setsigdefault(&attr, &defaultsig);
@@ -138,7 +128,7 @@
if (err == 0) {
savedpid = pid;
do {
- pid = _wait4(savedpid, &pstat, 0, (struct rusage *)0);
+ pid = wait4(savedpid, &pstat, 0, (struct rusage *)0);
} while (pid == -1 && errno == EINTR);
if (pid == -1) pstat = -1;
} else if (err == ENOMEM || err == EAGAIN) { /* as if fork failed */
@@ -147,17 +137,14 @@
pstat = W_EXITCODE(127, 0); /* couldn't exec shell */
}
- (void)_sigaction(SIGINT, &intact, NULL);
- (void)_sigaction(SIGQUIT, &quitact, NULL);
- (void)_sigprocmask(SIG_SETMASK, &oldsigblock, NULL);
+ (void)sigaction(SIGINT, &intact, NULL);
+ (void)sigaction(SIGQUIT, &quitact, NULL);
+ (void)sigprocmask(SIG_SETMASK, &oldsigblock, NULL);
#if __DARWIN_UNIX03
pthread_mutex_unlock(&__systemfn_mutex);
#endif /* __DARWIN_UNIX03 */
return(pstat);
-#endif /* TARGET_OS_IPHONE && (TARGET_OS_SIMULATOR || !TARGET_OS_IOS) */
}
-__weak_reference(__system, system);
-__weak_reference(__system, _system);
#pragma clang diagnostic pop
|