clean up
This commit is contained in:
parent
625527799c
commit
ae5b3fc390
9
term.c
9
term.c
|
@ -7,7 +7,6 @@
|
|||
#endif
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
|
||||
// compile with gcc term.c -lutil
|
||||
|
@ -31,10 +30,6 @@ int main(int argc, char **argv) {
|
|||
shell = "/bin/sh";
|
||||
}
|
||||
|
||||
// find the shell's name
|
||||
char *slash = strrchr(shell, '/');
|
||||
char *name = slash == NULL ? shell : slash + 1;
|
||||
|
||||
// allocate a pty, fork, inititialize file descriptor
|
||||
int fdm = -1; // allocate file descriptor
|
||||
pid_t pid = forkpty(&fdm, NULL, NULL, NULL);
|
||||
|
@ -46,9 +41,9 @@ int main(int argc, char **argv) {
|
|||
setenv("TERM", "ansi", 1);
|
||||
// execute shell
|
||||
if (login) {
|
||||
execlp(name, shell, "-l", "-i", NULL);
|
||||
execlp(shell, shell, "-l", "-i", NULL);
|
||||
} else {
|
||||
execlp(name, shell, NULL);
|
||||
execlp(shell, shell, NULL);
|
||||
}
|
||||
perror("exec bash failed");
|
||||
} else { // parent
|
||||
|
|
Loading…
Reference in New Issue