Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister

Re^3: Suffering with buffering - how to wake 'less'

by BrowserUk (Patriarch)
on Jan 13, 2010 at 19:59 UTC ( #817268=note: print w/replies, xml ) Need Help??

in reply to Re^2: Suffering with buffering - how to wake 'less'
in thread Suffering with buffering - how to wake 'less'

Once less has displayed the first screen full, it stops reading the pipe and waits for instructions from the keyboard. The pipe fills and won't accept anymore from the producer, so it blocks on the write until the pipe empties. Which it won't until you hit the space bar or similar. uses a shared queue as a buffer between two threads, The read thread just keeps reading and pushing to the queue. The write thread reads from that queue and writes to the pipe. Because the two are asynchronous, when the write thread blocks because the pipe to less is full, the reader just carries on filling up memory until the producer finishes.

The downside is that if the producer produces sufficient output, the perl process will eventually run out of memory and die.

Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.
  • Comment on Re^3: Suffering with buffering - how to wake 'less'

Replies are listed 'Best First'.
Re^4: Suffering with buffering - how to wake 'less'
by benizi (Hermit) on Jan 13, 2010 at 23:23 UTC

    There it is, thanks. I was lost by the disconnect between the two facts: 1. 'less stops after one screen' and 2. 'perl produces more than one screenful before it pauses'.

Log In?

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://817268]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others taking refuge in the Monastery: (3)
As of 2022-10-03 07:37 GMT
Find Nodes?
    Voting Booth?
    My preferred way to holiday/vacation is:

    Results (13 votes). Check out past polls.