1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859 |
- #define openpty __openpty
- #define login_tty __login_tty
- #include <sys/types.h>
- #include <termios.h>
- #include <unistd.h>
- #include <utmp.h>
- #include <pty.h>
- int
- forkpty (amaster, name, termp, winp)
- 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;
- }
- }
|