Re: [m-users.] Calling exit(3) from a foreign predicate
Volker Wysk <[email protected]> Fri, 26 Jan 2024 10:24:41 +0100
| Newsgroups | gmane.comp.lang.mercury.general |
|---|---|
| Message-ID | <[email protected]> |
Am Freitag, dem 26.01.2024 um 15:44 +1100 schrieb Julien Fischer: > 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. > > What mercury_runtime_terminate() does is the following: > > 1. Runs any user-defined module finalizers. > 2. Runs standard library finalization. > 3. Some stuff to turn of debugging (if that is enabled). > 4. Writes out trace counts (if the user has requested that). > 5. Turns of profiling and writes out profiling results (if some form of > profiling is enabled). > 6. Writes out tabling statistics (if requested). > 7. Shuts down engines (in low-level C .par grades) > 8. Writes out memory usages reports (if requested by user) > 9. Return mercury_exit_status to its caller. (This list should go into the Mercury User Guide...) That's a lot, even though most is done only when turned on explicitly. I think I better do an orderly shutdown. > I suspect the issue you are encountering is with (7), since that code > assumes that all engines are idle and if you still have threads running > at that point some of them won't be. > > In the normal course of events, the runtime code that invokes main/2 > blocks at the completion of main/2 until all threads terminate. Cheers, Volker _______________________________________________ users mailing list [email protected] https://lists.mercurylang.org/listinfo/users