… | |
… | |
32 | #include <cstdlib> |
32 | #include <cstdlib> |
33 | #include <cstring> |
33 | #include <cstring> |
34 | #include <csignal> |
34 | #include <csignal> |
35 | |
35 | |
36 | #include <sys/types.h> |
36 | #include <sys/types.h> |
|
|
37 | #include <sys/stat.h> |
37 | #include <unistd.h> |
38 | #include <unistd.h> |
38 | #include <fcntl.h> |
39 | #include <fcntl.h> |
39 | |
40 | |
40 | #ifdef HAVE_SYS_IOCTL_H |
41 | #ifdef HAVE_SYS_IOCTL_H |
41 | # include <sys/ioctl.h> |
42 | # include <sys/ioctl.h> |
42 | #endif |
43 | #endif |
43 | #if defined(HAVE_DEV_PTMX) && defined(HAVE_SYS_STROPTS_H) |
44 | #if defined(HAVE_DEV_PTMX) && defined(HAVE_SYS_STROPTS_H) |
44 | # include <sys/stropts.h> /* for I_PUSH */ |
45 | # include <sys/stropts.h> /* for I_PUSH */ |
45 | #endif |
46 | #endif |
46 | #ifdef HAVE_ISASTREAM |
47 | #if defined(HAVE_ISASTREAM) && defined(HAVE_STROPTS_H) |
47 | # include <stropts.h> |
48 | # include <stropts.h> |
48 | #endif |
49 | #endif |
49 | #if defined(HAVE_PTY_H) |
50 | #if defined(HAVE_PTY_H) |
50 | # include <pty.h> |
51 | # include <pty.h> |
51 | #elif defined(HAVE_LIBUTIL_H) |
52 | #elif defined(HAVE_LIBUTIL_H) |
… | |
… | |
127 | int pfd; |
128 | int pfd; |
128 | char *slave; |
129 | char *slave; |
129 | |
130 | |
130 | slave = _getpty (&pfd, O_RDWR | O_NONBLOCK | O_NOCTTY, 0622, 0); |
131 | slave = _getpty (&pfd, O_RDWR | O_NONBLOCK | O_NOCTTY, 0622, 0); |
131 | |
132 | |
132 | if (slave != NULL) { |
133 | if (slave != NULL) |
|
|
134 | { |
133 | *ttydev = strdup (slave); |
135 | *ttydev = strdup (slave); |
134 | return pfd; |
136 | return pfd; |
135 | } |
137 | } |
136 | |
138 | |
137 | return -1; |
139 | return -1; |
138 | } |
140 | } |
139 | |
141 | |
140 | #elif defined(HAVE_DEV_PTC) |
142 | #elif defined(HAVE_DEV_PTC) |
… | |
… | |
246 | * documentation is really unclear about whether it is any close () on |
248 | * documentation is really unclear about whether it is any close () on |
247 | * the master side or the last close () - i.e. a proper STREAMS dismantling |
249 | * the master side or the last close () - i.e. a proper STREAMS dismantling |
248 | * close () - on the master side which causes a hang up to be sent |
250 | * close () - on the master side which causes a hang up to be sent |
249 | * through - Geoff Wing |
251 | * through - Geoff Wing |
250 | */ |
252 | */ |
251 | # ifdef HAVE_ISASTREAM |
253 | #if defined(HAVE_ISASTREAM) && defined(HAVE_STROPTS_H) |
252 | if (isastream (fd_tty) == 1) |
254 | if (isastream (fd_tty) == 1) |
253 | # endif |
255 | # endif |
254 | { |
256 | { |
255 | ioctl (fd_tty, I_PUSH, "ptem"); |
257 | ioctl (fd_tty, I_PUSH, "ptem"); |
256 | ioctl (fd_tty, I_PUSH, "ldterm"); |
258 | ioctl (fd_tty, I_PUSH, "ldterm"); |