#include #include #include #include int main(int argc, char **argv) { if (argc < 2) { printf("usage: %s ROM\n", argv[0]); return 1; } char *rom = argv[1]; // find term.rom int fdm = -1; // allocate file descriptor // allocate a pty, fork, inititialize file descriptor pid_t pid = forkpty(&fdm, NULL, NULL, NULL); if (pid < 0) { // failure printf("fork failed"); return 1; } else if (pid == 0) { // child setenv("TERM", "ansi", 1); execlp("bash", "bash", NULL); // exec bash } else { // parent struct winsize ws = {23, 80, 8, 12}; // rows, cols, xps, ypx ioctl(fdm, TIOCSWINSZ, &ws); // set term window size dup2(fdm, 0); // use fdm for stdin dup2(fdm, 1); // use fdm for stdout execlp("uxnemu", "uxnemu", rom, NULL); // exec uxnemu } }