Sebastian Sardina wrote:
>
> (this is a follow-up of a a somehow old message)
>
> that's nice Joachim, thanks.
> now I should add a restartable_goal/1 fact for every
> predicate that performs a system call, like for instance
> wait_for_input/3.
I haven't heard of wait_for_input/3 (maybe you mean select/3),
but I came up with the following list, which I believe covers
everything:
% Builtins that can raise EINTR and can be restarted after that
restartable_builtin(accept(_,_,_)).
restartable_builtin(cd(_)).
restartable_builtin(close(_)).
restartable_builtin(connect(_,_)).
restartable_builtin(select(_,_,_)).
restartable_builtin(wait(_,_)).
We'll make this restart-behaviour the default in the next release.
>
> I have a program that basically waits for input with wait_for_input/3
> BUT at the same time there may be after-events to do something every say
> 3 seconds. then wait_for_input/3 will be interrupted with error.
>
> is this the "clean" way of solving this problem? I guess that waiting on
> a set of streams is something natural for many programs...
>
> Thanks
>
> Sebastian
>
> > But I agree with your general point that wait/2 should not
> > abort when interrupted. You can achieve this by modifying
> > the corresponding error handler as follows:
> >
> > :- set_error_handler(170, my_system_error_handler/2).
> >
> > my_system_error_handler(E, Goal) :-
> > (
> > errno_id("Interrupted system call"),
> > restartable_goal(Goal)
> > ->
> > call(Goal)
> > ;
> > error(default(E), Goal)
> > ).
> >
> > restartable_goal(wait(_,_)).
> >
> >
> >
> > --
> > Joachim Schimpf / phone: +44 20 7594 8187
> > IC-Parc, Imperial College / mailto:J.Schimpf@ic.ac.uk
> > London SW7 2AZ, UK / http://www.icparc.ic.ac.uk/eclipse
> >
--
Joachim Schimpf / phone: +44 20 7594 8187
IC-Parc, Imperial College / mailto:J.Schimpf@ic.ac.uk
London SW7 2AZ, UK / http://www.icparc.ic.ac.uk/eclipse