Re: halt with timing
Jan Wielemaker <[email protected]>
| Newsgroups | gmane.comp.ai.prolog.swi |
|---|---|
| Message-ID | <[email protected]> |
On 12/06/2013 03:05 PM, Gabor Monostori wrote:
> Hi there,
>
> I made something simple and became puzzled, can you help me?
>
> I put the following lines into pl.ini
>
> :- write('Hello World'),
> alarm(2,halt,Id,[]).
>
> If i start swipl-win.exe(Wind7) the code works; after two seconds the
> window is closed.
>
> If i start swipl.exe after two seconds the console is still there, but if i
> want to do something after typing new line and pressing 'Enter' the console
> closes. Here I expected the window to be closed also promptly.
>
> Is this a bug, side effect or I do smt wrongly?
Many blocking system calls do not process the alarm event. Worse,
this set varies from OS to OS. Alarm events are mostly useful for
interrupting long computations. On some streams (again depending
on the OS) you can set a read timeout using set_stream/2. The only
guarantee here is that this works on sockets on all platforms.
So, for what are you planning to use alarms?
Cheers --- Jan