help-bash
[Top][All Lists]
Advanced

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

Re: [Help-bash] Question: Capturing command output (on-screen keyword co


From: Matthew Giassa
Subject: Re: [Help-bash] Question: Capturing command output (on-screen keyword colorizer/prettifier).
Date: Thu, 06 Oct 2016 11:49:27 -0700
User-agent: Workspace Webmail 6.5.1

Is it possible to hook the bash builtin malloc? I'm not explicitly
calling calloc/malloc, so I wonder if it's something else that could be
triggering this behavior, such as pthread_create. If that's the case, I
guess I'll need to drop threads and instead issue an additional
fork/exec call.

Also, I had considered creating a pseudo terminal to intercept the data
in place of the pipe approach I'm utilizing, but I believe BASh
installed a SIGCHLD signal handler, so using grantpt would be error
prone. Is this assumption correct?

Thanks!

> -------- Original Message --------
> Subject: Re: [Help-bash] Question: Capturing command output (on-screen
> keyword colorizer/prettifier).
> From: Chet Ramey <address@hidden>
> Date: Thu, October 06, 2016 9:28 am
> To: Matthew Giassa <address@hidden>, address@hidden
> Cc: address@hidden
> 
> 
> On 10/5/16 8:35 PM, Matthew Giassa wrote:
> > I managed to get 99% of the way there. I used dup()/pipe()/dup2() and
> > hooked fork() to redirect stdout for bash and child processes to a
> > dedicated per-process pipe. I then spawn a dedicated (detached) worker
> > thread after forking which reads in the pipe, and then sends it merrily
> > along to the PTS/TTY (doesn't yet inject color codes).
> > 
> > I've noticed the following undesired behavior though when I initially
> > start BASh:
> > Case 1:
> >     malloc: .././subst.c:8902: assertion botched
> >     free: start and end chunk sizes differ
> >     Aborting...
> >     malloc: unknown:0: assertion botched
> >     free: start and end chunk sizes differ
> >     Aborting...Aborted (core dumped)
> 
> As I recall, this happens when the functions in the LD_PRELOAD use a
> different malloc (in this case, the libc malloc) than the malloc the
> rest of the bash code uses (the builtin bash one).  I believe this has
> come up before.
> 
> -- 
> ``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/



reply via email to

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