Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Bug#856587: fake-tty shared object or command line tool

32 views
Skip to first unread message

Patrick Schleizer

unread,
Mar 2, 2017, 1:10:03 PM3/2/17
to
Package: moreutils
Severity: whishlist
X-Debbugs-CC: whonix...@whonix.org

feature request:

fake-tty [application] - fools application into detecting being run
inside a tty

I am not a C coder, but at least a shared object looks easy to implement.

echo "int isatty(int fd) { return 1; }" | gcc -O2 -fpic -shared -ldl -o
"fake-tty.so" -xc -

usage:

LD_PRELOAD+=" fake-tty.so"

LD_PRELOAD="$LD_PRELOAD" apt-get "$@" 2>&1 | tee -a "$logfile"

(Preserves colors and download speed in terminal output that would
otherwise be eaten by using the pipe.)

use case:

1)
http://stackoverflow.com/questions/1401002/trick-an-application-into-thinking-its-stdin-is-interactive-not-a-pipe/26263980#26263980

python -c 'import pty, sys; pty.spawn(sys.argv[1:])' \
| apt-get "$@" 2>&1 \
| tee -a "$logfile"

2)
http://unix.stackexchange.com/questions/347970/how-to-create-a-real-copy-of-file-descriptor-stdout-and-stderr-without-using-unb

non-alternatives:

- script(1) man page says "It is not recommended to run script in
non-interactive shells.".

- unbuffer(1) does not correctly return the exit code if the process is
killed. Has a dependency on tcl.

Could you ship such fake-tty command line tool or shared object for
LD_PRELOAD with moreutils please?

Best regards,
Patrick

Jakub Wilk

unread,
Oct 31, 2022, 10:10:04 AM10/31/22
to
* Patrick Schleizer <adre...@riseup.net>, 2017-03-02 18:07:
>unbuffer(1) does not correctly return the exit code if the process is
>killed. Has a dependency on tcl.

Have a look at pipetty(1) from colorized-logs.
It's written in C and has better (although not perfect) error handling.

--
Jakub Wilk

Jakub Wilk

unread,
Oct 31, 2022, 11:00:03 AM10/31/22
to
* Patrick Schleizer <adre...@riseup.net>, 2017-03-02 18:07:
>- unbuffer(1) does not correctly return the exit code if the process is
>killed.

I've reported that as #1023201.

--
Jakub Wilk
0 new messages