coloredstderr (0.2, 2014-06-22)

Last updated 2016-09-11

coloredstderr is a small library which uses LD_PRELOAD to color stderr. It “follows” dups, has minimal performance overhead and can ignore certain binaries (requires /proc).

Like all solutions using LD_PRELOAD it only works with dynamically linked binaries. Statically linked binaries, for example valgrind, are not supported. setuid binaries are also not supported (LD_PRELOAD disabled for security reasons).

Most other existing solutions use a second process which colors its input and pipe stderr to it. However this creates different runtime behaviour resulting in a different ordering of the output. Partial lines (no newline) also often cause problems. coloredstderr handles these cases correctly.


It was inspired by stderred [2]. Similar solutions (using LD_PRELOAD) include:

  • stderred [1], but doesn’t “follow” dups (I somehow missed it when looking for existing implementations)

  • stderred [2], but only hooks write()

coloredstderr is licensed under GPL 3 (or later).

Requirements

  • C99 compiler (variable length arrays)

  • dynamic linker/loader which supports LD_PRELOAD (e.g. GNU/Linux’s or FreeBSD’s ld.so)

Supported Systems

Tested on GNU/Linux, FreeBSD and Mac OS X (partial support). Should work on all POSIX systems which support LD_PRELOAD (with minor modifications).

Usage

Add the following settings to your shell configuration:

LD_PRELOAD=/absolute/path/to/libcoloredstderr.so
COLORED_STDERR_FDS=2,
export LD_PRELOAD COLORED_STDERR_FDS

Also see README in tarball.

Download

Current development happens in the git repository (also browsable as Gitweb):

git clone https://ruderich.org/simon/coloredstderr/coloredstderr.git

Last updated 2016-09-11

Impressum Datenschutzerklärung