[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Help-bash] Question: Capturing command output (on-screen keyword co
From: |
Chet Ramey |
Subject: |
Re: [Help-bash] Question: Capturing command output (on-screen keyword colorizer/prettifier). |
Date: |
Wed, 5 Oct 2016 10:18:05 -0400 |
User-agent: |
Mozilla/5.0 (Macintosh; Intel Mac OS X 10.11; rv:45.0) Gecko/20100101 Thunderbird/45.3.0 |
On 10/4/16 9:20 PM, Matthew Giassa wrote:
>
> While I'm able to get the output of echo commands, the PS1/PS2/etc
> variables, and so on, I can't seem to get the output of the "ls" command
> for
> example. I've checked the symbols used to write data out to the console
> via the
> following: readelf --dyn-syms /bin/bash | grep -i -e write -e printf
>
> Output:
> 6: 0000000000000000 0 FUNC GLOBAL DEFAULT UND
> address@hidden (5)
> 13: 0000000000000000 0 FUNC GLOBAL DEFAULT UND
> address@hidden (5)
> 39: 0000000000000000 0 FUNC GLOBAL DEFAULT UND
> address@hidden (2)
> 98: 0000000000000000 0 FUNC GLOBAL DEFAULT UND
> address@hidden (8)
> 142: 0000000000000000 0 FUNC GLOBAL DEFAULT UND
> address@hidden (5)
> 152: 0000000000000000 0 FUNC GLOBAL DEFAULT UND
> address@hidden (5)
> 191: 0000000000000000 0 FUNC GLOBAL DEFAULT UND
> address@hidden (2)
> 192: 0000000000000000 0 FUNC GLOBAL DEFAULT UND
> address@hidden (5)
> 213: 0000000000000000 0 FUNC GLOBAL DEFAULT UND
> address@hidden (5)
>
> So as far as I can see, I'm hooking all of the typical commands BASh
> would use to write to the console, yet there is still output which I'm
> not
> capturing.
>
> Is there yet another function BASh uses which I would need to hook in
> order to capture all command output within the LD_PRELOAD'ed C library?
Since `ls' is a separate executable, it handles input and output itself.
Bash doesn't get involved with it.
If you want to hook the separate child processes to your LD_PRELOAD
library, you need to make sure that LD_PRELOAD survives the fork and
is available to the loader. That might be as simple as exporting the
variable.
--
``The lyf so short, the craft so long to lerne.'' - Chaucer
``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, UTech, CWRU address@hidden http://cnswww.cns.cwru.edu/~chet/