script: use lib/pty-session

This patch consolidate pseudo-terminal stuff in util-linux. From now
there is only one implementation used in su(1) --pty, scriptlive(1)
and script(1).

The new stuff is based on the original script(1) -- it means poll()
and signalfd() based.

Note that script(1) code does not provide fallback for systems/libc
where is no openpty().

Signed-off-by: Karel Zak <kzak@redhat.com>
This commit is contained in:
Karel Zak 2019-10-03 14:33:25 +02:00
parent f3e55e3e7c
commit ec10634e7e
5 changed files with 347 additions and 627 deletions

View File

@ -1822,7 +1822,7 @@ UL_REQUIRES_LINUX([setarch])
AM_CONDITIONAL([BUILD_SETARCH], [test "x$build_setarch" = xyes]) AM_CONDITIONAL([BUILD_SETARCH], [test "x$build_setarch" = xyes])
UL_BUILD_INIT([script], [check]) UL_BUILD_INIT([script], [check])
UL_REQUIRES_HAVE([script], [sys_signalfd_h], [sys/signalfd.h header]) UL_REQUIRES_HAVE([script], [pty])
AM_CONDITIONAL([BUILD_SCRIPT], [test "x$build_script" = xyes]) AM_CONDITIONAL([BUILD_SCRIPT], [test "x$build_script" = xyes])
UL_BUILD_INIT([scriptreplay], [yes]) UL_BUILD_INIT([scriptreplay], [yes])

View File

@ -1,12 +1,12 @@
if BUILD_SCRIPT if BUILD_SCRIPT
usrbin_exec_PROGRAMS += script usrbin_exec_PROGRAMS += script
dist_man_MANS += term-utils/script.1 dist_man_MANS += term-utils/script.1
script_SOURCES = term-utils/script.c lib/monotonic.c script_SOURCES = term-utils/script.c \
lib/pty-session.c \
include/pty-session.h \
lib/monotonic.c
script_CFLAGS = $(AM_CFLAGS) -Wno-format-y2k script_CFLAGS = $(AM_CFLAGS) -Wno-format-y2k
script_LDADD = $(LDADD) libcommon.la $(REALTIME_LIBS) script_LDADD = $(LDADD) libcommon.la $(MATH_LIBS) $(REALTIME_LIBS) -lutil
if HAVE_UTIL
script_LDADD += -lutil
endif
if HAVE_UTEMPTER if HAVE_UTEMPTER
script_LDADD += -lutempter script_LDADD += -lutempter
endif endif

File diff suppressed because it is too large Load Diff

View File

@ -1,3 +1,3 @@
Script started, file is /dev/null Script started, output log file is '/dev/null'.
Hallo World Hallo World
Script done, file is /dev/null Script done.

View File

@ -1,8 +1,8 @@
record script output with timing record script output with timing
Script started, file is typescript Script started, output log file is 'typescript', timing file is 'timingfile'.
hello world hello world
all done all done
Script done, file is typescript Script done.
replay script output replay script output
hello world hello world
all done all done