Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-pascal / 2001-03

Sleep until key press?

7 messages · 3 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Stephen Hurd

Is it possible using the linux version to have a program sleep until a key is pressed?

I've looked for such a thing... even tried:

procedure wait_for_key;
var keystroke:text;
begin
assign(keystroke,'');
selecttext(keystroke);
end;

with no luck, it seem as though the only way to put a process into the sleep state is
by using the pause procedure... which doesn't return on a keypress.

Stephen Hurd
to Jonas Maebe
On Sat, 31 Mar 2001, Stephen Hurd wrote: > Is it possible using the linux version to have a program sleep until a

key

Show quoted text 6 lines
> is pressed? Have a look at the code for readkey in the Linux Crt unit. Jonas

I'm not seeing anything there... I uses select(), it uses delay(), it doesn't go to sleep. It stays as a runnable process.

Stephen Hurd
to Stephen Hurd
I'm not seeing anything there... I uses select(), it uses delay(), it doesn't go to sleep. It stays as a runnable process.

My bad... was using the wrong version of a unit... ReadKey does make the process sleep.

Sorry for the hassle.

Jonas Maebe
to Stephen Hurd: key I'm not seeing anything there... I uses select(), it uses delay(), it doesn't go to…
Stephen Hurd wrote 7 lines
> > Is it possible using the linux version to have a program sleep until a > > key is pressed? > > Have a look at the code for readkey in the Linux Crt unit. I'm not seeing anything there... I uses select(), it uses delay(), it doesn't go to sleep. It stays as a runnable process.

But it doesn't use any cpu cycles while waiting. What's the difference with sleep then?

Jonas