Re: Break under Windows NT

From: Xavier Leroy (Xavier.Leroy@inria.fr)
Date: Tue Mar 16 1999 - 14:50:55 MET


Date: Tue, 16 Mar 1999 14:50:55 +0100
From: Xavier Leroy <Xavier.Leroy@inria.fr>
To: Don Syme <dsyme@microsoft.com>, caml-list@inria.fr
Subject: Re: Break under Windows NT
In-Reply-To: <39ADCF833E74D111A2D700805F1951EF0F00BA69@RED-MSG-06>; from Don Syme on Mon, Mar 15, 1999 at 06:26:51AM -0800

> Is it true that under the Windows NT version of OCaml there's no easy way of
> sending the equivalent of a SIGINT to a OCaml process and have OCaml raise
> an exception?

As far as I know, Win32 has no equivalent to Unix signals (i.e. the
ability for a process to interrupt asynchronously another process).

For "console" applications, the C library implements some notion of
signals (for ANSI C compatibility), but SIGINT is only generated when
the user types ctrl-C or ctrl-break at the keyboard, or when the
program sends SIGINT to itself; it cannot be generated from another
process.

A classic alternative to signals is to use multiple threads: one
thread synchronously waits for some external notification, then fakes
a pending signal condition in the other thread that is running the
Caml code. However, Caml threads do not have (yet) the ability to
raise exceptions in other threads, so one has to implement this
solution in C. If you tell me in more details what you're trying to
achieve, maybe I could send you some sample code.

> Or have I missed something? I need to be able to
> asynchronously break long running computations under NT. BTW I'm also using
> OCamlTK.

OCamlTk programs are not console-only applications, and thus have an
event loop that runs periodically. This adds more opportunities for
implementing inter-process notification, via periodic polling or
by posting special events on the application's message queue; however,
I haven't looked into this in details.

- Xavier Leroy



This archive was generated by hypermail 2b29 : Sun Jan 02 2000 - 11:58:21 MET