Skip to content

Commit a7cbad8

Browse files
committed
Prevent IllegalStateException during 'kill -5' command
1 parent 321280c commit a7cbad8

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

kotlinx-coroutines-debug/src/AgentPremain.kt

+7-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,13 @@ internal object AgentPremain {
2121
private fun installSignalHandler() {
2222
try {
2323
Signal.handle(Signal("TRAP")) { // kill -5
24-
DebugProbes.dumpCoroutines()
24+
if (DebugProbes.isInstalled) {
25+
// Case with 'isInstalled' changed between this check-and-act is not considered
26+
// a real debug probes use-case, thus is not guarded against.
27+
DebugProbes.dumpCoroutines()
28+
} else {
29+
println("""Cannot perform coroutines dump, debug probes are disabled""")
30+
}
2531
}
2632
} catch (t: Throwable) {
2733
System.err.println("Failed to install signal handler: $t")

0 commit comments

Comments
 (0)