Path: utzoo!utgpu!water!watmath!clyde!rutgers!ames!pasteur!ucbvax!CORY.BERKELEY.EDU!dillon From: dillon@CORY.BERKELEY.EDU (Matt Dillon) Newsgroups: comp.sys.amiga.tech Subject: Re: Killing a task using SetExcept() Message-ID: <8803080923.AA17348@cory.Berkeley.EDU> Date: 8 Mar 88 09:23:10 GMT Sender: usenet@ucbvax.BERKELEY.EDU Lines: 34 >Hello, > I am trying to design a neat way to kill tasks spawned by my programs. >I want to use exception processing via SetExcept and the tc_ExceptCode field. >What I mean to do is point tc_ExceptCode at my cleanup routine and use >SetExcept to point a signal that will start thisup from within my task. >My question is how will the system react to a RemTask() call from within the >exception? The more I think about this the more it seems to me that I am >going to crash the system- what is the true wisdom on this? > >Thanks! Since the exception handler runs in user mode in the task's context on the task's stack, you should be able to RemTask(NULL) fine.... of course, the only way to find out is to try! There is a major problem though, that you don't want to kill a task while it is in the middle of a library call. Usually, one needs a more synchronous way of killing a dedicated child task... in the above method, you are not guarenteed that the task will be killed immediately after you send the Signal(). I usually do it it like this: Totally synchronous method: Use one of the preallocated signals to mean "please die", and signal the task in question with that signal. The task would then Forbid(), signal you back, and RemTask(NULL) (while still forbid()en). When you get the signal back, the task is guarenteed to not exist anymore and you can clean up its resources (memory, seglist...) -Matt