On 06/01/2012 09:46, Makarius wrote:
On Thu, 5 Jan 2012, Ian Zimmerman wrote:
[17]matica:~$ poly
Poly/ML 5.4.1 Release
fun main () = raise Domain ;
val main = fn: unit -> 'a
PolyML.export ("foo", main);
val it = (): unit
[19]matica:~$ cc -o foo foo.o -lpolymain -lpolyml
[20]matica:~$ ./foo
[21]matica:~$ echo $?
0
I find this quite surprising, am I the only one?
I know that I can easily work around it by including an exception
catching wrapper in main, but it seems to me that wrapper should be in
libpolymain ..
The current code forks off the root function and terminates when the
last thread exits. It does not treat the first thread as special and it
is possible for that thread to fork other threads and for it to exit
while leaving the Poly process running. Since a thread can exit either
by returning or by raising an uncaught exception it isn't clear when a
non-zero return code should be generated.
That seemed to me to be a reasonable approach but I'm prepared to
consider other possibilities. The alternative would be to wrap the main
function as
(f (); OS.Process.exit OS.Process.success)
handle _ => OS.Process.exit OS.Process.failure
I suppose it would be possible for the initial thread to exit with
Thread.exit to avoid calling OS.Process.exit if it wanted to leave other
threads running.
David
_______________________________________________
polyml mailing list
[email protected]
http://lists.inf.ed.ac.uk/mailman/listinfo/polyml