On Thu, 24 Jun 2021 17:51:01 +0300 "Yordan Karadzhov (VMware)" <y.karadz@xxxxxxxxx> wrote: > The new APIs can be used to dump the content of "trace_pipe" into a > file or directly to "stdout". The "splice" system call is used to > moves the data without copying. The new functionality is essentially > identical to what 'trace-cmd show -p' does. > > Signed-off-by: Yordan Karadzhov (VMware) <y.karadz@xxxxxxxxx> > So I did some investigations here, and found that splice() is not guaranteed to work on a terminal output. To overcome this, I decided to have the print create another pipe, and pass that to the stream code. The if something was read, it would read the pipe. It required changing the return of the functions to return the amount transferred, so that I can differentiate between "EOF" with nothing read, and something read. Because I couldn't get the pipe to not block on read if there was no content in it. :-/ Anyway, I submitted a v4 with the changes I made, and it appears to work. I haven't tested it that much, so it may still have bugs. We could optimize it to just use the splice output first (stream first), and if that returns with EINVAL, which is the expected error on a non functioning stdout, we could then switch to this alternate method. Although, the stream would have read some of the pipe and lost the data, which is not what we want, so a test of stdout would need to be made with splice first. :-/ -- Steve