0

I would like to read /sys/kernel/debug/tracing/trace_pipe in non-blocking way using Linux command-line tools. For instance, cat cannot be used, because it will be blocked. This is similar to this, with the difference that I don't want to use Python.

Community
  • 1
  • 1
Javad
  • 313
  • 3
  • 13

1 Answers1

1

The concept of ‘non-blocking’ doesn't apply to command-line tools. However, you could run an instance of cat in the background by appending an ampersand to the invocation, like so:

cat /sys/kernel/debug/tracing/trace_pipe &

Now, the command returns immediately, and every time a line is readable from the file, it gets printed to the terminal (and messes up whatever you were typing).

You could also use tail -F if the file itself doesn't block.

user3426575
  • 1,723
  • 12
  • 18
  • This is indeed a solution, however, I would like to sample `trace_pipe` every second. Your approach increases the system load which is undesirable for my use case. – Javad Nov 27 '14 at 03:46
  • It's the same as with `cat`: if you want the command to run in the background, add an `&` at the end of the invocation. This shouldn't increase the system load any more than running it the normal way does. – user3426575 Nov 27 '14 at 21:46