From 1ebe79dd628f009108c3d6dbdbfbfc69b7a6933d Mon Sep 17 00:00:00 2001 From: Nicholas Marriott Date: Mon, 23 Jan 2017 12:26:06 +0000 Subject: [PATCH] Use forkpty() except on OpenBSD. --- pty.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/pty.c b/pty.c index 05a02ef0..6db623f9 100644 --- a/pty.c +++ b/pty.c @@ -19,13 +19,14 @@ #include #include #include +#ifdef __OpenBSD__ #include +#endif #include #include #include #include -#include int pty_open(int *); pid_t pty_fork(int, int *, char *, size_t, struct winsize *); @@ -33,15 +34,20 @@ pid_t pty_fork(int, int *, char *, size_t, struct winsize *); int pty_open(int *fd) { +#ifdef __OpenBSD__ *fd = open(PATH_PTMDEV, O_RDWR|O_CLOEXEC); if (*fd < 0) return (-1); +#else + *fd = -1; +#endif return (0); } pid_t pty_fork(int ptmfd, int *fd, char *name, size_t namelen, struct winsize *ws) { +#ifdef __OpenBSD__ struct ptmget ptm; pid_t pid; @@ -64,4 +70,7 @@ pty_fork(int ptmfd, int *fd, char *name, size_t namelen, struct winsize *ws) *fd = ptm.cfd; close(ptm.sfd); return (pid); +#else + return (forkpty(fd, name, NULL, ws)); +#endif }