This source file includes following definitions.
- rpl_forkpty
- forkpty
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 #include <config.h>
18
19
20 #include <pty.h>
21
22 #if HAVE_FORKPTY
23
24
25 # undef forkpty
26 int
27 rpl_forkpty (int *amaster, char *name, struct termios const *termp,
28 struct winsize const *winp)
29 {
30
31 return forkpty (amaster, name, (struct termios *) termp,
32 (struct winsize *) winp);
33 }
34
35 #else
36
37 # include <pty.h>
38 # include <unistd.h>
39
40 extern int login_tty (int slave_fd);
41
42 int
43 forkpty (int *amaster, char *name,
44 const struct termios *termp, const struct winsize *winp)
45 {
46 int master, slave, pid;
47
48 if (openpty (&master, &slave, name, termp, winp) == -1)
49 return -1;
50
51 switch (pid = fork ())
52 {
53 case -1:
54 close (master);
55 close (slave);
56 return -1;
57
58 case 0:
59
60 close (master);
61 if (login_tty (slave))
62 _exit (1);
63 return 0;
64
65 default:
66
67 *amaster = master;
68 close (slave);
69 return pid;
70 }
71 }
72
73 #endif