GNU bug report logs -
#72536
[PATCH] tap: new `--merge-prefix' option to prefix stderr before merging
Previous Next
Reported by: Richard Hansen <rhansen <at> rhansen.org>
Date: Fri, 9 Aug 2024 08:40:01 UTC
Severity: normal
Tags: patch
Done: Karl Berry <karl <at> freefriends.org>
Bug is archived. No further changes may be made.
Full log
View this message in rfc822 format
On 2/21/25 18:21, Richard Hansen wrote:
> On 2/20/25 19:29, Jacob Bachmeyer wrote:
>> Could we filter both stdout and stderr through functions that
>> timestamp each line, then merge the two and sort on the timestamps?
>
> Unfortunately this wouldn't help---it would be subject to the same
> reordering race condition. The timestamp value that is added to a
> line would depend on when the kernel woke up the reading
> thread/process, so the timestamps wouldn't always accurately represent
> the time the test program wrote the line. If the kernel woke up the
> stderr and stdout threads in the opposite order of writing, then the
> timestamps would be in the wrong order.
Now we are getting into the "crazy hack" category, but how about an
LD_PRELOAD module that gets put in the test process and wraps write(3)
to add timestamps?
On systems with GNU libc, that module could replace stdout and stderr
with custom streams that prepend timestamps to the start of each line
before calling write(2).
For an even crazier (but even less portable) hack, I seem to recall that
there is a way to attach a BPF program to a process as a syscall filter
in current Linux kernels. Could we use *that* to wrap write(2) and add
timestamps? :-)
-- Jacob
This bug report was last modified 97 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.