[Overview][Constants][Types][Procedures and functions][Variables] Reference for unit 'oldlinux' (#rtl)

NanoSleep

Suspend process for a short time

Declaration

Source position: oldlinux.pp line 1490

function NanoSleep(

  const req: timespec;

  var rem: timespec

):LongInt;

Description

NanoSleepsuspends the process till a time period as specified in reqhas passed. Then the function returns. If the call was interrupted (e.g. by some signal) then the function may return earlier, and remwill contain the remaining time till the end of the intended period. In this case the return value will be -1, and LinuxErrorwill be set to EINTR

If the function returns without error, the return value is zero.

Errors

If the call was interrupted, -1 is returned, and LinuxErroris set to EINTR. If invalid time values were specified, then -1 is returned and LinuxErroris set to EINVAL.

See also

Pause

  

Wait for a signal

Alarm

  

Schedule an alarm signal to be delivered

Example

program example72;

{ Program to demonstrate the NanoSleep function. }

uses oldlinux;

Var
  Req,Rem : TimeSpec;
  Res : Longint;

begin
  With Req do
    begin
    tv_sec:=10;
    tv_nsec:=100;
    end;
  Write('NanoSleep returned : ');
  Flush(Output);
  Res:=(NanoSleep(Req,rem));
  Writeln(res);
  If (res<>0) then
    With rem do
      begin
      Writeln('Remaining seconds     : ',tv_sec);
      Writeln('Remaining nanoseconds : ',tv_nsec);
      end;
end.