use perror

This commit is contained in:
~d6 2023-02-04 16:34:05 -05:00
parent 926d13ce55
commit 8aca0bb01a
1 changed files with 3 additions and 1 deletions

4
term.c
View File

@ -15,16 +15,18 @@ int main(int argc, char **argv) {
pid_t pid = forkpty(&fdm, NULL, NULL, NULL); pid_t pid = forkpty(&fdm, NULL, NULL, NULL);
if (pid < 0) { // failure if (pid < 0) { // failure
printf("fork failed"); perror("fork failed");
return 1; return 1;
} else if (pid == 0) { // child } else if (pid == 0) { // child
setenv("TERM", "ansi", 1); setenv("TERM", "ansi", 1);
execlp("bash", "bash", NULL); // exec bash execlp("bash", "bash", NULL); // exec bash
perror("exec bash failed");
} else { // parent } else { // parent
struct winsize ws = {23, 80, 8, 12}; // rows, cols, xps, ypx struct winsize ws = {23, 80, 8, 12}; // rows, cols, xps, ypx
ioctl(fdm, TIOCSWINSZ, &ws); // set term window size ioctl(fdm, TIOCSWINSZ, &ws); // set term window size
dup2(fdm, 0); // use fdm for stdin dup2(fdm, 0); // use fdm for stdin
dup2(fdm, 1); // use fdm for stdout dup2(fdm, 1); // use fdm for stdout
execlp("uxnemu", "uxnemu", rom, NULL); // exec uxnemu execlp("uxnemu", "uxnemu", rom, NULL); // exec uxnemu
perror("exec uxnemu failed");
} }
} }