Close nicely
This commit is contained in:
parent
b7660a1920
commit
0061d91c7b
|
@ -127,6 +127,7 @@ start_fork_pty(Uint8 *d)
|
|||
static void
|
||||
start_fork_pipe(Uint8 *d)
|
||||
{
|
||||
pid_t pid;
|
||||
if(child_mode & 0x01) {
|
||||
/* parent writes to child's stdin */
|
||||
if(pipe(to_child_fd) == -1) {
|
||||
|
@ -135,7 +136,6 @@ start_fork_pipe(Uint8 *d)
|
|||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if(child_mode & 0x06) {
|
||||
/* parent reads from child's stdout and/or stderr */
|
||||
if(pipe(from_child_fd) == -1) {
|
||||
|
@ -144,8 +144,7 @@ start_fork_pipe(Uint8 *d)
|
|||
return;
|
||||
}
|
||||
}
|
||||
|
||||
pid_t pid = fork();
|
||||
pid = fork();
|
||||
if(pid < 0) { /* failure */
|
||||
d[0x6] = 0xff;
|
||||
fprintf(stderr, "fork failure\n");
|
||||
|
@ -180,9 +179,9 @@ start_fork_pipe(Uint8 *d)
|
|||
static void
|
||||
kill_child(Uint8 *d, int options)
|
||||
{
|
||||
int wstatus;
|
||||
if(child_pid) {
|
||||
kill(child_pid, 9);
|
||||
int wstatus;
|
||||
if(waitpid(child_pid, &wstatus, options)) {
|
||||
d[0x6] = 1;
|
||||
d[0x7] = WEXITSTATUS(wstatus);
|
||||
|
|
|
@ -102,6 +102,7 @@ emu_end(Uxn *u)
|
|||
XDestroyImage(ximage);
|
||||
XDestroyWindow(display, window);
|
||||
XCloseDisplay(display);
|
||||
exit(0);
|
||||
return u->dev[0x0f] & 0x7f;
|
||||
}
|
||||
|
||||
|
@ -143,8 +144,7 @@ emu_event(Uxn *u)
|
|||
XPutImage(display, window, DefaultGC(display, 0), ximage, 0, 0, PAD, PAD, w, h);
|
||||
} break;
|
||||
case ClientMessage:
|
||||
emu_end(u);
|
||||
exit(0);
|
||||
u->dev[0x0f] = 0x80;
|
||||
break;
|
||||
case KeyPress: {
|
||||
KeySym sym;
|
||||
|
@ -225,7 +225,7 @@ display_init(void)
|
|||
}
|
||||
|
||||
static int
|
||||
emu_run(Uxn *u, char *rom)
|
||||
emu_run(Uxn *u)
|
||||
{
|
||||
int i = 1, n;
|
||||
char expirations[8];
|
||||
|
@ -287,7 +287,7 @@ main(int argc, char **argv)
|
|||
u.dev[0x17] = argc - i;
|
||||
if(uxn_eval(&u, PAGE_PROGRAM)) {
|
||||
console_listen(&u, i, argc, argv);
|
||||
emu_run(&u, boot_rom);
|
||||
emu_run(&u);
|
||||
}
|
||||
return emu_end(&u);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue