Housekeeping

This commit is contained in:
neauoire 2023-11-11 19:44:15 -08:00
parent 7a9bc710e6
commit 520373d598
3 changed files with 8 additions and 17 deletions

View File

@ -33,14 +33,13 @@ WITH REGARD TO THIS SOFTWARE.
/* process */
static char *fork_args[32];
static pid_t child_pid;
static int child_mode;
static int pty_fd;
static int to_child_fd[2];
static int from_child_fd[2];
static int saved_in;
static int saved_out;
static pid_t child_pid;
struct winsize ws = {24, 80, 8, 12};
static void
@ -179,12 +178,12 @@ start_fork_pipe(Uint8 *d)
}
static void
kill_child(Uint8 *d)
kill_child(Uint8 *d, int options)
{
if(child_pid) {
kill(child_pid, 9);
int wstatus;
if(waitpid(child_pid, &wstatus, 0)) {
if(waitpid(child_pid, &wstatus, options)) {
d[0x6] = 1;
d[0x7] = WEXITSTATUS(wstatus);
clean_after_child();
@ -196,7 +195,7 @@ static void
start_fork(Uxn *u, Uint8 *d)
{
fflush(stderr);
kill_child(d);
kill_child(d, 0);
child_mode = d[0x5];
parse_args(u, d);
if(child_mode >= 0x80)
@ -211,15 +210,7 @@ console_dei(Uxn *u, Uint8 addr)
Uint8 port = addr & 0x0f, *d = &u->dev[addr & 0xf0];
switch(port) {
case 0x6:
case 0x7:
if(child_pid) {
int wstatus;
if(waitpid(child_pid, &wstatus, WNOHANG)) {
d[0x6] = 1;
d[0x7] = WEXITSTATUS(wstatus);
clean_after_child();
}
}
case 0x7: kill_child(d, WNOHANG);
}
return d[port];
}
@ -230,7 +221,7 @@ console_deo(Uxn *u, Uint8 *d, Uint8 port)
FILE *fd = NULL;
switch(port) {
case 0x5: /* Console/dead */ start_fork(u, d); break;
case 0x6: /* Console/exit*/ kill_child(d); break;
case 0x6: /* Console/exit*/ kill_child(d, 0); break;
case 0x8: fd = stdout; break;
case 0x9: fd = stderr; break;
}

View File

@ -262,7 +262,7 @@ main(int argc, char **argv)
return system_error("usage", "uxn11 [-v] file.rom [args...]");
/* Read flags */
if(argv[i][0] == '-' && argv[i][1] == 'v')
return system_version("Uxn11 - Graphical Varvara Emulator", "9 Nov 2023");
return system_version("Uxn11 - Graphical Varvara Emulator", "11 Nov 2023");
if(!emu_init())
return system_error("Init", "Failed to initialize varvara.");
if(!system_init(&u, (Uint8 *)calloc(0x10000 * RAM_PAGES, sizeof(Uint8)), argv[i++]))

View File

@ -71,7 +71,7 @@ main(int argc, char **argv)
return system_error("usage", "uxncli [-v] file.rom [args..]");
/* Read flags */
if(argv[i][0] == '-' && argv[i][1] == 'v')
return system_version("Uxncli - Console Varvara Emulator", "9 Nov 2023");
return system_version("Uxncli - Console Varvara Emulator", "11 Nov 2023");
if(!system_init(&u, (Uint8 *)calloc(0x10000 * RAM_PAGES, sizeof(Uint8)), argv[i++]))
return system_error("Init", "Failed to initialize uxn.");
/* Game Loop */