-
Notifications
You must be signed in to change notification settings - Fork 14
/
Copy pathpatch_loslibc.txt
50 lines (42 loc) · 1.14 KB
/
patch_loslibc.txt
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
--- tmp/lua-5.4.4/src/loslib.c 2022-01-13 12:24:42
+++ lua-5.4.4/src/loslib.c 2024-12-03 10:04:52
@@ -20,6 +20,7 @@
#include "lauxlib.h"
#include "lualib.h"
+#include "ios_error.h"
/*
@@ -98,6 +99,8 @@
#endif /* } */
+#include "ios_error.h"
+
/* }================================================================== */
@@ -141,9 +144,13 @@
static int os_execute (lua_State *L) {
const char *cmd = luaL_optstring(L, 1, NULL);
- int stat;
- errno = 0;
- stat = system(cmd);
+ int stat;
+ errno = 0;
+ int pid = ios_fork();
+ int status;
+ ios_system(cmd);
+ waitpid(pid, &status, 0);
+ stat = WEXITSTATUS(status);
if (cmd != NULL)
return luaL_execresult(L, stat);
else {
@@ -399,6 +406,13 @@
status = (int)luaL_optinteger(L, 1, EXIT_SUCCESS);
if (lua_toboolean(L, 2))
lua_close(L);
+ // iOS: reset signal handling before leaving
+ struct sigaction sa;
+ sa.sa_handler = SIG_DFL;
+ sa.sa_flags = 0;
+ sigemptyset(&sa.sa_mask); /* do not mask any signal */
+ sigaction(SIGINT, &sa, NULL);
+ // end iOS
if (L) exit(status); /* 'if' to avoid warnings for unreachable 'return' */
return 0;
}