term stuff
This commit is contained in:
parent
3d81b6eeca
commit
b0e380caaa
24
term.c
24
term.c
|
@ -1,7 +1,6 @@
|
|||
#include <pty.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <sys/ioctl.h>
|
||||
#include <unistd.h>
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue