[m-users.] Calling exit(3) from a foreign predicate

Volker Wysk post at volker-wysk.de
Fri Jan 26 00:40:06 AEDT 2024


Am Donnerstag, dem 25.01.2024 um 16:05 +1100 schrieb Julien Fischer:
> Hi,
> 
> On Wed, 24 Jan 2024, Volker Wysk wrote:
> 
> > Calling exit(3), without calling mercury_runtime_terminate() before, works.
> > All thread are terminated and the program exits. It's only
> > mercury_runtime_terminate() that blocks. I've read somewhere that it waits
> > for all threads to terminate. Is there another function which doesn't? I'd
> > like to properly shut down the Mercury runtime, if possible.
> 
> Yes, Mercury programs do not terminate until all threads created by
> calls to spawn/3 terminate; mercury_runtime_terminate() will block until
> this occurs. As it stands at the moment, you will need to arrange for
> any remaining threads to terminate.

I see. 

But I can still call exit(3) and do a hard exit to the Mercury runtime and
all threads, not performing shutdown. (Except for what the exit(3) function
does.)

That doesn't seem to be that bad to me. Or am I missing something that
should, in any case, be terminated properly?

Cheers,
Volker


More information about the users mailing list