commit 520373d
neauoire
·
2023-11-12 03:44:15 +0000 UTC
parent 7a9bc71
Housekeeping
3 files changed,
+8,
-17
+6,
-15
1@@ -33,14 +33,13 @@ WITH REGARD TO THIS SOFTWARE.
2
3 /* process */
4 static char *fork_args[32];
5-static pid_t child_pid;
6 static int child_mode;
7 static int pty_fd;
8 static int to_child_fd[2];
9 static int from_child_fd[2];
10 static int saved_in;
11 static int saved_out;
12-
13+static pid_t child_pid;
14 struct winsize ws = {24, 80, 8, 12};
15
16 static void
17@@ -179,12 +178,12 @@ start_fork_pipe(Uint8 *d)
18 }
19
20 static void
21-kill_child(Uint8 *d)
22+kill_child(Uint8 *d, int options)
23 {
24 if(child_pid) {
25 kill(child_pid, 9);
26 int wstatus;
27- if(waitpid(child_pid, &wstatus, 0)) {
28+ if(waitpid(child_pid, &wstatus, options)) {
29 d[0x6] = 1;
30 d[0x7] = WEXITSTATUS(wstatus);
31 clean_after_child();
32@@ -196,7 +195,7 @@ static void
33 start_fork(Uxn *u, Uint8 *d)
34 {
35 fflush(stderr);
36- kill_child(d);
37+ kill_child(d, 0);
38 child_mode = d[0x5];
39 parse_args(u, d);
40 if(child_mode >= 0x80)
41@@ -211,15 +210,7 @@ console_dei(Uxn *u, Uint8 addr)
42 Uint8 port = addr & 0x0f, *d = &u->dev[addr & 0xf0];
43 switch(port) {
44 case 0x6:
45- case 0x7:
46- if(child_pid) {
47- int wstatus;
48- if(waitpid(child_pid, &wstatus, WNOHANG)) {
49- d[0x6] = 1;
50- d[0x7] = WEXITSTATUS(wstatus);
51- clean_after_child();
52- }
53- }
54+ case 0x7: kill_child(d, WNOHANG);
55 }
56 return d[port];
57 }
58@@ -230,7 +221,7 @@ console_deo(Uxn *u, Uint8 *d, Uint8 port)
59 FILE *fd = NULL;
60 switch(port) {
61 case 0x5: /* Console/dead */ start_fork(u, d); break;
62- case 0x6: /* Console/exit*/ kill_child(d); break;
63+ case 0x6: /* Console/exit*/ kill_child(d, 0); break;
64 case 0x8: fd = stdout; break;
65 case 0x9: fd = stderr; break;
66 }
+1,
-1
1@@ -262,7 +262,7 @@ main(int argc, char **argv)
2 return system_error("usage", "uxn11 [-v] file.rom [args...]");
3 /* Read flags */
4 if(argv[i][0] == '-' && argv[i][1] == 'v')
5- return system_version("Uxn11 - Graphical Varvara Emulator", "9 Nov 2023");
6+ return system_version("Uxn11 - Graphical Varvara Emulator", "11 Nov 2023");
7 if(!emu_init())
8 return system_error("Init", "Failed to initialize varvara.");
9 if(!system_init(&u, (Uint8 *)calloc(0x10000 * RAM_PAGES, sizeof(Uint8)), argv[i++]))
+1,
-1
1@@ -71,7 +71,7 @@ main(int argc, char **argv)
2 return system_error("usage", "uxncli [-v] file.rom [args..]");
3 /* Read flags */
4 if(argv[i][0] == '-' && argv[i][1] == 'v')
5- return system_version("Uxncli - Console Varvara Emulator", "9 Nov 2023");
6+ return system_version("Uxncli - Console Varvara Emulator", "11 Nov 2023");
7 if(!system_init(&u, (Uint8 *)calloc(0x10000 * RAM_PAGES, sizeof(Uint8)), argv[i++]))
8 return system_error("Init", "Failed to initialize uxn.");
9 /* Game Loop */