Ron Reiter
Ron Reiter

Reputation: 3934

Can I read the console buffer using UNIX system calls somehow?

I want to create a smart debugging utiliy that reads the stderr that was already printed to the tty (say, 1000 lines back).

Is there any type of UNIX API call that allows me to do so? I couldn't find one.

Upvotes: 1

Views: 857

Answers (1)

Thomas Dickey
Thomas Dickey

Reputation: 54525

No, there is no "UNIX API" call which would do this. A few special cases may be useful:

  • most terminal emulators provide a scrollback area which you can view. The number of lines for this is usually configurable; the default size is usually small, e.g., 100 lines.
  • some console terminals, e.g., Linux, have a similar feature (see for example 18. Scrolling, in the Keyboard and Console HOW-TO).

A few terminal implementations can be told to provide a screen dump. As a rule, those are limited to the currently-visible screen:

As a rule, there also are no escape sequences to do this since that approach (allowing "any" program to see the screen contents) is often regarded as a security violation.

Upvotes: 1

Related Questions