Skip to content

Export isChildProcess() #245

Open
Open

Description

@hadley

Since it's sometimes useful to have a script that behaves differently when its a job.

Activity

  1. romainfrancois commented on Jan 7, 2022

    @romainfrancois
    Contributor

    Perhaps using these environment variables:

    https://github.com/rstudio/rstudio/blob/d39088c5be134078cef0fdf85006f551360fb38a/src/cpp/session/SessionAsyncRProcess.cpp#L171

    isChildProcess <- function() !identical(Sys.getenv("RSTUDIOAPI_IPC_REQUESTS_FILE"), "")

    I'm not sure where the function would live though.

  2. hadley commented on Jan 7, 2022

    @hadley
    MemberAuthor

    Maybe rstudioapi?

  3. kevinushey commented on Jan 7, 2022

    @kevinushey
    Contributor

    An identical function lives in rstudioapi -- maybe we should export it?

    rstudioapi/R/remote.R

    Lines 2 to 4 in 96fad1d

    isChildProcess <- function() {
    !is.na(Sys.getenv("RSTUDIOAPI_IPC_REQUESTS_FILE", unset = NA))
    }

  4. kevinushey commented on Jan 7, 2022

    @kevinushey
    Contributor

    I kind of wonder if we want a different name, though -- those environment variables are set for specific kinds of R child processes, not for all of them. (In other words, RStudio might run some R processes where isChildProcess() would return FALSE just because it didn't go through that particular code path for launching R.)

  5. romainfrancois commented on Jan 10, 2022

    @romainfrancois
    Contributor

    isJob() perhaps ?

  6. added this to the milestone on Jan 26, 2022
  7. modified the milestones: , Elsbeth Geranium (2022.10.0) on May 9, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions