[R-SIG-Mac] Sys.sleep() in R.app can't be interrupted
Simon Urbanek
@|mon@urb@nek @end|ng |rom R-project@org
Thu Apr 2 01:20:02 CEST 2026
Duncan,
thanks. I can replicate it. Something must have happened with the meshing of the event loops, because Sys.sleep() is not supposed to actually sleep the whole time, it should run the system event loop to check for interrupts periodically, but apparently doesn't.
Cheers,
Simon
> On 2 Apr 2026, at 08:32, Duncan Murdoch <murdoch.duncan using gmail.com> wrote:
>
> This might be a well known issue, but I couldn't spot it in the FAQ or bug list or mailing list archives.
>
> If you execute Sys.sleep(60) in R.app, the command can't be interrupted by ESC or Cmd-C until it is done. R.app becomes completely unresponsive.
>
> The number 60 isn't important, as far as I can tell this is true for any sleep time.
>
> A simple workaround is to limit the duration of Sys.sleep() calls, e.g. using a function like this:
>
> Sleep <- function(duration) {
> seconds <- floor(duration)
> for (i in seq_len(seconds))
> Sys.sleep(1)
> Sys.sleep(duration - seconds)
> }
>
> R.app handles interrupts every time Sys.sleep returns, so this means the biggest delay is 1 second.
>
> In case this isn't universal, here's my session info:
>
> ```
> R version 4.5.3 (2026-03-11)
> Platform: aarch64-apple-darwin20
> Running under: macOS Sequoia 15.7.4
>
> Matrix products: default
> BLAS: /Library/Frameworks/R.framework/Versions/4.5-arm64/Resources/lib/libRblas.0.dylib
> LAPACK: /Library/Frameworks/R.framework/Versions/4.5-arm64/Resources/lib/libRlapack.dylib; LAPACK version 3.12.1
>
> locale:
> [1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8
>
> time zone: America/Toronto
> tzcode source: internal
>
> attached base packages:
> [1] stats graphics grDevices utils datasets methods base
>
> loaded via a namespace (and not attached):
> [1] compiler_4.5.3
> ```
>
> Duncan Murdoch
>
> _______________________________________________
> R-SIG-Mac mailing list
> R-SIG-Mac using r-project.org
> https://stat.ethz.ch/mailman/listinfo/r-sig-mac
>
More information about the R-SIG-Mac
mailing list