Breaking from Readlines in console and job termination


I mistakenly wrote

readLines() -> quotes

in the command line (without specifying a file/connection), which made of course stdin be the connection. Well I experienced the expected behavior of being stuck having the R session waiting for input; I am a bit surprised that a ^D does not terminate that wait, as usually it would mean EOF, but maybe readLines doesn't respect EOF.
In any case, I have a few questions:

  1. Is there anyway to break out of this without killing the session?

  2. If not, I'm aware of two options to stop a session: terminate R and restart R. I think that the difference is that the former also closes the project, losing all state (Global Env, libraries are detached, etc), where the latter just restart the interactive R session, but I'm not sure. Also, wouldn't even the weaker form lose any data that is in G.env, not giving me the option to save .RData? (my setting at the moment is that I've been ask whether to keep the state in .RData, as usually I rather not to avoid clutter)

  3. Finally, what about jobs that are running? are they going to terminate regardless of the way I terminate my session?


[Adding to the initial post]

I tried my way out of it w.r.t. saving the state, using jobs :blush:
There is the option to run them with a copy of the global environment (which I usually avoid), but I could do that and run save.image. So far so good, except that my objects sit in a separate environment that I am attaching once the project is loaded --- I'm using it to avoid clutter, saving only what I actually want to retain in that environment and the temporary variable/computation is wiped out upon project termination. (Attaching this environment makes it easily accessible for reading from command line, and I only need to use explicit assignment to it for objects I care about -- which is main reason for its existence)
Unfortunately using this cleaner solution works again me now, as even running with a copy of the global environment, does not include all state stored in attached objects/environments.

Any advice or tricks to get out of this mess would be highly appreciated

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.