[erlang-questions] Terminating process after timeout
Ladislav Lenart
lenartlad@REDACTED
Tue Jun 26 11:39:10 CEST 2007
Kirill Zaborski wrote:
> Wow I've forgot to check timer module, thanks Ladislav!
> Using timer:send_after would require for the spawned process to listen
> to the messages in receive loop, or it will require additinal process
> for it.
> I think it could be done easier using timer:kill_after/2
Well, you right of course.
Just one tiny little remark: the worker process being killed
using timer:kill_after/2 will not get a change to cleanup after
itself...
Ladislav Lenart
> On 6/26/07, Ladislav Lenart <lenartlad@REDACTED> wrote:
> Kirill Zaborski wrote:
>> > I was wondering - what is the right way to to spawn a process and kill
>> > it if it runs more than some threshold? The only way I see at the
>> > moment is to spawn process aditional process which will check if the
>> > worker procees finished after the specified time and if not it will
>> > kill the worker.
>> > Is there some other ways to implement the desired behaviour?
>>
>> The process can alternatively plan a timer event via timer:send_after/2,3
>> for example in its init to send itself a (deferred) message to
>> terminate...
>>
>> Hope this helps,
>>
>> Ladislav Lenart
>>
>>
>> _______________________________________________
>> erlang-questions mailing list
>> erlang-questions@REDACTED
>> http://www.erlang.org/mailman/listinfo/erlang-questions
>>
>
>
More information about the erlang-questions
mailing list