Skip to content

Commit c33d887

Browse files
committed
Clarify difference between exit and halt, add TODO comment
1 parent 9ce1dfa commit c33d887

1 file changed

Lines changed: 10 additions & 4 deletions

File tree

core/native/src/main/scala/cats/effect/IOApp.scala

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -413,14 +413,14 @@ trait IOApp {
413413
// threads to gracefully complete their work, and managed
414414
// environments to execute their own shutdown hooks.
415415
} else {
416-
halt(ec.code)
416+
System.exit(ec.code)
417417
}
418418

419419
done = true
420420

421421
case _: CancellationException =>
422422
// Do not report cancelation exceptions but still exit with an error code.
423-
halt(1)
423+
System.exit(1)
424424

425425
case t: Throwable =>
426426
if (UnsafeNonFatal(t)) {
@@ -448,8 +448,14 @@ trait IOApp {
448448
}
449449
}
450450

451-
private[this] def halt(status: Int): Unit = System.exit(status)
452-
451+
private[this] def halt(status: Int): Unit = {
452+
// TODO: This should be `Runtime#halt` (i.e.,
453+
// TODO: not call shutdown hooks), but that is
454+
// TODO: unavailable on scala-native. Note,
455+
// TODO: that `stdlib.exit` seems to be the
456+
// TODO: same as `System.exit` currently.
457+
System.exit(status)
458+
}
453459
}
454460

455461
object IOApp {

0 commit comments

Comments
 (0)