In R, I am facing this unpleasant issue. I am not sure if it is a bug or how to avoid this behaviour.
Pressing ^C on R console (tested on Linux) will kill background jobs. See the following examples:
Example 1 - using pipe:
conn1 <- pipe("ts | tee LOG.txt", open = "wt") # ts is from package moreutils
sink(conn1)
sink(conn1, type = "message")
1
# Apr 16 23:17:43 [1] 1
2
# Apr 16 23:17:46 [1] 2
Every output goes to LOG.txt and console, with timestamp. Now press ENTER and Ctrl-C:
3
4
# you get no output because the pipe got killed!
Example 2 - running another R process in the background (used e.g. in doRedis/startLocalWorkers()):
system("R --slave -e 'while (TRUE) { A <- rnorm(100000); Sys.sleep(0.05) }'", wait = FALSE)
# Loading required package: stats
You can see the process running. Now press ENTER and Ctrl-C:
# Execution halted
Is this a feature or a bug? Definitely not desired. Also not usual (for example bash will also not kill background process with Ctrl-C). How do I make Ctrl-C to not kill background processes in R?
Tested on R version 3.6.0 (2019-04-26), CentOS Linux release 7.6.1810 (Core).