123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051 |
- #include <sys/types.h>
- #include <termios.h>
- #include <unistd.h>
- #include <utmp.h>
- #include <pty.h>
- 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;
- }
- }
|