Sign in Join

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

Mailing lists / fpc-devel / 2009-11

sleep and SIGINT on 2.4.0

3 messages · 3 people ·

Reply by email Subscribe to this list Your subscription

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

beld

hi, freepascal developers

I found a question about 2.4.0 yesterday and do some check today.

in Kylix 3: the Ctrl+C whill break the "sleep" call, and fpc 2.2.4 do same.

but in 2.4.0, Ctrl+C is handled, but "sleep" is sleeping yet.

//--------- testing code begin ---------------------------------------------
uses
  {$ifdef fpc}
  baseunix,
  {$else}
  Libc,
  {$endif}
  SysUtils;
procedure sig_int(sig: Longint); cdecl;
begin
  writeln(' -> [Ctrl+C]: ', FormatDateTime('hh:nn:ss.zzz', Now));
end;
begin
  {$ifdef fpc}
  fpsignal(SIGINT, signalhandler(@sig_int));
  {$else}
  signal(SIGINT, @sig_int);
  {$endif}
  writeln(FormatDateTime('hh:nn:ss.zzz', Now));
  sleep(10 * 1000);
  writeln(FormatDateTime('hh:nn:ss.zzz', Now));
end.
//--------- testing code end ---------------------------------------------

beld

2009-11-26

Reply by email

Tomas Hajny
to beld
beld wrote 8 lines
hi, freepascal developers I found a question about 2.4.0 yesterday and do some check today. in Kylix 3: the Ctrl+C whill break the "sleep" call, and fpc 2.2.4 do same. but in 2.4.0, Ctrl+C is handled, but "sleep" is sleeping yet.

Note to people replying to this message - the author is not subscribed to the list (at least not with this e-mail address) so make sure to include his address in Cc: when replying.

Tomas

Reply by email

Jonas Maebe
to beld: hi, freepascal developers I found a question about 2.4.0 yesterday and do some check…

beld wrote on do, 26 nov 2009:

Show quoted text 7 lines
hi, freepascal developers I found a question about 2.4.0 yesterday and do some check today. in Kylix 3: the Ctrl+C whill break the "sleep" call, and fpc 2.2.4 do same. but in 2.4.0, Ctrl+C is handled, but "sleep" is sleeping yet.

Many cases were fixed in FPC 2.4.0 whereby interrupted system calls were not restarted. This was also done for the sysutils sleep() function, so that if the sleep is interrupted for whatever reason, it is resumed afterwards.

It is debatable what the correct behaviour is of a high level function. I personally think that if you want to rely on Unix behaviour (i.e., that a signal interrupts a system call), you should call the unix functions directly rather than high level wrappers in sysutils.

Jonas

---------------------------------------------------------------- This message was sent using IMP, the Internet Messaging Program.

Reply by email