Skip to content

Commit

Permalink
rts_checkSchedStatus: exit the thread, not the process, when Interrupted
Browse files Browse the repository at this point in the history
This means that when the process is shutting down, if we have calls to
foreign exports in progress, they get forcibly terminated as before,
but now they only shut down the calling thread rather than the whole
process (with -threaded).

This came up in a discussion started by Akio Takano on ghc-users.
  • Loading branch information
simonmar committed May 10, 2013
1 parent dca18dc commit 674cf90
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion rts/RtsAPI.c
Expand Up @@ -522,7 +522,16 @@ rts_checkSchedStatus (char* site, Capability *cap)
stg_exit(EXIT_FAILURE);
case Interrupted:
errorBelch("%s: interrupted", site);
stg_exit(EXIT_FAILURE);
#ifdef THREADED_RTS
// The RTS is shutting down, and the process will probably
// soon exit. We don't want to preempt the shutdown
// by exiting the whole process here, so we just terminate the
// current thread. Don't forget to release the cap first though.
rts_unlock(cap);
shutdownThread();
#else
stg_exit(EXIT_FAILURE);
#endif
default:
errorBelch("%s: Return code (%d) not ok",(site),(rc));
stg_exit(EXIT_FAILURE);
Expand Down

0 comments on commit 674cf90

Please sign in to comment.