diff --git a/term.c b/term.c index cc63c1b..ba44732 100644 --- a/term.c +++ b/term.c @@ -1,7 +1,6 @@ #include #include #include -#include #include int main(int argc, char **argv) { @@ -10,20 +9,25 @@ int main(int argc, char **argv) { return 1; } char *rom = argv[1]; - int fd = -1; + int fdm = -1; + setenv("TERM", "ansi", 1); + pid_t pid = forkpty(&fdm, NULL, NULL, NULL); - pid_t pid = forkpty(&fd, NULL, NULL, NULL); - if (pid == 0) { + if (pid < 0) { + // failure + printf("fork failed"); + return 1; + } else if (pid == 0) { // child - setenv("TERM", "ansi", 1); + setsid(); execlp("bash", "bash"); } else { // parent - char *argp = {0, 40, 0, 79, 0, 8, 0, 8}; // HHHH: height, width, 8, 8 - ioctl(fd, TIOCSWINSZ, argp); - - dup2(fd, STDIN); - dup2(dup(fd), STDOUT); + // rows, cols, xpixels, ypixels (little endian) + char argp[] = {23, 0, 80, 0, 8, 0, 12, 0}; + ioctl(fdm, TIOCSWINSZ, argp); + dup2(fdm, 0); + dup2(fdm, 1); execlp("uxnemu", "uxnemu", rom); } } diff --git a/term.py b/term.py index f5b9217..ce657ae 100755 --- a/term.py +++ b/term.py @@ -32,7 +32,7 @@ def main(): # set the terminal size ###cols, rows = 79, 40 cols, rows = 80, 24 - size = struct.pack("HHHH", rows, cols, 8, 8) + size = struct.pack("HHHH", rows, cols, 8, 12) fcntl.ioctl(fd, termios.TIOCSWINSZ, size) # use fd for the terminals stdin/stdout