1
0
mirror of https://gitlab.com/libvirt/libvirt.git synced 2024-12-22 17:34:18 +03:00

util: add detection of openpty function

All UNIX platforms we care about have openpty() in the libutil
library. Use of pty.h must also be made conditional, excluding
Win32.

Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
This commit is contained in:
Daniel P. Berrangé 2020-01-07 16:19:52 +00:00
parent 913707bb8d
commit f650e86703
4 changed files with 21 additions and 1 deletions

View File

@ -2342,3 +2342,6 @@ exclude_file_name_regexp--sc_prohibit_strcmp = \
exclude_file_name_regexp--sc_prohibit_backslash_alignment = \
^build-aux/syntax-check\.mk$$
exclude_file_name_regexp--sc_prohibit_always_true_header_tests = \
^src/util/virfile\.c$$

View File

@ -383,10 +383,13 @@ dnl Availability of various common headers (non-fatal if missing).
AC_CHECK_HEADERS([\
ifaddrs.h \
libtasn1.h \
util.h \
libutil.h \
linux/magic.h \
mntent.h \
net/ethernet.h \
netinet/tcp.h \
pty.h \
pwd.h \
stdarg.h \
syslog.h \
@ -430,6 +433,7 @@ dnl header could be found.
AM_CONDITIONAL([HAVE_LIBTASN1], [test "x$ac_cv_header_libtasn1_h" = "xyes"])
AC_CHECK_LIB([intl],[gettext],[])
AC_CHECK_LIB([util],[openpty],[])
dnl

View File

@ -282,6 +282,7 @@ libvirt_util_la_CFLAGS = \
$(NULL)
libvirt_util_la_LIBADD = \
-lm \
$(OPENPTY_LIBS) \
$(CAPNG_LIBS) \
$(YAJL_LIBS) \
$(LIBNL_LIBS) \

View File

@ -27,7 +27,19 @@
#include <passfd.h>
#include <fcntl.h>
#include <pty.h>
#include <termios.h>
#ifdef HAVE_PTY_H
/* Linux openpty */
# include <pty.h>
#endif /* !HAVE_PTY_H */
#ifdef HAVE_UTIL_H
/* macOS openpty */
# include <util.h>
#endif /* !HAVE_LIBUTIL_H */
#ifdef HAVE_LIBUTIL_H
/* FreeBSD openpty */
# include <libutil.h>
#endif /* !HAVE_LIBUTIL_H */
#include <sys/stat.h>
#include <sys/types.h>
#include <sys/socket.h>