help-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Help-bash] How to create a real copy of file descriptors stdout / s


From: Patrick Schleizer
Subject: Re: [Help-bash] How to create a real copy of file descriptors stdout / stderr?
Date: Wed, 01 Mar 2017 15:36:00 +0000

Patrick Schleizer:
> The following worked for me.
> 
> echo "int isatty(int fd) { return 1; }" | gcc -O2 -fpic -shared -ldl -o
> "$isatty_so_file" -xc -
> 
> LD_PRELOAD+=" $isatty_so_file
> 
> LD_PRELOAD="$LD_PRELOAD" apt-get "$@" 2>&1 | tee -a "$logfile"
> 
> gcc compilation on the fly seems crazy but was a worthwhile test.
> 
> Is there some pre-build command line tool isatty or shared object isatty.so?

Need to specify what I meant. Sorry for the confusion.

What the shared object for LD_PRELOAD with "int isatty(int fd) { return
1; }" apparently does not not showing if a tool is running inside a tty
or not. It's fooling the application asking for "am I running in a tty"
with "yes". It overwrites the C function "am I running in a tty" with
"always return yes". That's my understanding from testing it.

Is there a pre-build command line tool for that?

(I am asking, because then there is a chance I can install it using the
package manager of my distribution, which would be a much cleaner solution.)

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




reply via email to

[Prev in Thread] Current Thread [Next in Thread]