diff --git a/configure.in b/configure.in
index 6f67478..dcbb3cb 100644
--- a/configure.in
+++ b/configure.in
@@ -351,7 +351,7 @@ AC_CHECK_HEADERS(sys/select.h sys/syslimits.h sys/termios.h sys/un.h sys/wait.h
 AC_HEADER_TIOCGWINSZ
 
 # Check for PTY handling functions.
-AC_CHECK_FUNCS([cfmakeraw fork setsid setpgid getpgid getpt grantpt unlockpt ptsname ptsname_r tcgetattr tcsetattr])
+AC_CHECK_FUNCS([cfmakeraw fork setsid setpgid getpgid getpt grantpt unlockpt posix_openpt ptsname ptsname_r tcgetattr tcsetattr])
 
 # Pull in the right libraries for various functions which might not be
 # bundled into an exploded libc.
diff --git a/src/pty.c b/src/pty.c
index a4c8c07..f675a07 100644
--- a/src/pty.c
+++ b/src/pty.c
@@ -812,7 +812,9 @@ static int
 _vte_pty_getpt(GError **error)
 {
 	int fd, flags, rv;
-#ifdef HAVE_GETPT
+#ifdef HAVE_POSIX_OPENPT
+	fd = posix_openpt(O_RDWR | O_NOCTTY);
+#elif defined(HAVE_GETPT)
 	/* Call the system's function for allocating a pty. */
 	fd = getpt();
 #else
