use perror
This commit is contained in:
parent
926d13ce55
commit
8aca0bb01a
4
term.c
4
term.c
|
@ -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");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue