Re: halt with timing

Gabor Monostori <[email protected]>
Newsgroups gmane.comp.ai.prolog.swi
Message-ID <CAN5Lht-jmKVe=JdcJxpTPf49Aw6iD35jctEnsNLruGMtOgtzUQ@mail.gmail.com>
Jan, thank you for the answer!

My prolog code works as a server, but after a few queries it is not needed
anymore, so i want to shut down automatically.

regards,
Gábor






On Fri, Dec 6, 2013 at 3:47 PM, Jan Wielemaker <[email protected]> wrote:

> 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
>
>
-------------- next part --------------
HTML attachment scrubbed and removed
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.