12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455 |
- #include <sys/types.h>
- #include <termios.h>
- #include <unistd.h>
- #include <utmp.h>
- #include <pty.h>
- libutil_hidden_proto(openpty)
- libutil_hidden_proto(login_tty)
- int
- forkpty (int *amaster, char *name, struct termios *termp, struct winsize *winp)
- {
- int master, slave, pid;
- if (openpty (&master, &slave, name, termp, winp) == -1)
- return -1;
- switch (pid = fork ())
- {
- case -1:
- return -1;
- case 0:
-
- close (master);
- if (login_tty (slave))
- _exit (1);
- return 0;
- default:
-
- *amaster = master;
- close (slave);
- return pid;
- }
- }
|