From mboxrd@z Thu Jan 1 00:00:00 1970 Received: (from weis@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id OAA19792 for caml-redist; Thu, 11 May 2000 14:45:46 +0200 (MET DST) Received: from concorde.inria.fr (concorde.inria.fr [192.93.2.39]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id HAA01212 for ; Tue, 9 May 2000 07:31:37 +0200 (MET DST) Received: from localhost.localdomain (ike194.zip.com.au [210.23.146.194]) by concorde.inria.fr (8.8.7/8.8.7) with ESMTP id HAA11365 for ; Tue, 9 May 2000 07:31:33 +0200 (MET DST) Received: from maxtal.com.au (IDENT:root@localhost [127.0.0.1]) by localhost.localdomain (8.9.3/8.8.7) with ESMTP id PAA09042; Tue, 9 May 2000 15:32:56 +1000 Sender: weis Message-ID: <3917A308.24B90662@maxtal.com.au> Date: Tue, 09 May 2000 15:32:56 +1000 From: John Max Skaller X-Mailer: Mozilla 4.7 [en] (X11; I; Linux 2.2.12-20 i686) X-Accept-Language: en MIME-Version: 1.0 To: Markus Mottl CC: OCAML Subject: Re: how to kill native code threads? References: <200005060009.CAA17778@miss.wu-wien.ac.at> Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Markus Mottl wrote: > > Hello, > > the documentation of the "Thread.kill" function says that it only works for > bytecode-level threads. > > But how can I terminate native threads from outside? [This information from a coworker who is expert in threads, which I am not] You can't. There IS supposedly a way to do this in general, using Posix thread cancellation. It isn't clear that this will work correctly with Ocaml, however, and for this reason it isn't part of the threads library. [It also only works on Posix systems]. Where I work, there is a different problem: code is written in C++, and when a thread is cancelled, it is necessary to unwind the stack to execute destructors. Linux does not do this. I'm told Solaris tries. Posix requires certain functions check for cancellation. Unfortunately, there is a bug in the Posix specification, such that NOT all blocking calls perform the requisite check. This means Posix thread cancellation doesn't work properly in all cases. I can't remember the offending calls off hand, [connect?] but you need to add a manual check and use a non-blocking call in that case. Executive summary: there's no simple solution, not even in C. -- John (Max) Skaller, mailto:skaller@maxtal.com.au 10/1 Toxteth Rd Glebe NSW 2037 Australia voice: 61-2-9660-0850 checkout Vyper http://Vyper.sourceforge.net download Interscript http://Interscript.sourceforge.net