Q:

Why does running shiny start two Rscript processes on windows when launching from cmd line?

When I start an R script that runs a shiny app from the cmd line, it appears to launch two instances of Rscript.exe? I can always kill the smaller of the two and the app continues to run? Can someone elaborate on what is actually going on behind the scenes or tell me what I am doing wrong that is creating double processes?

super_simple.R
require(shiny)

app <- shinyApp(
  ui = bootstrapPage(
    numericInput('n', 'Number of obs', 100),
    plotOutput('plot')
  ),
  server = function(input, output) {
    output$plot <- renderPlot({ hist(runif(input$n)) })
  }
)

runApp(app, launch.browser = FALSE, port = 1234, host = "10.123.4.56")

Now if I launch this via the cmd line:
START Rscript --vanilla C:\Users\Jason\Projects\super_simple.R

At this point, I can point my browser to http://10.123.4.56:1234 and see the app. However, if I look at my running processes via: tasklist /FI "imagename eq rscript*" I see two Rscript.exe processes:

What I've determined, however, is that I can always kill the smaller of the two (e.g., taskkill /pid 9360 /f) and yet the app still functions in its entirety? NOTE: I have tried starting the command in the background via START \b ... but the outcome is the same.

A:

This is a general thing with the R scripting command-line utilities (Rscript.exe, R.exe, Rcmd.exe) and not specific to Shiny. All of these actually call Rterm.exe underneath to run the actual program in a separate process. 
Try Rscript.exe with  --verbose and you'll see what I mean:
> Rscript --verbose script.R
running
  'C:\PROGRA~1\R\R-34~1.0\bin\x64\Rterm.exe --slave --no-restore --file=script.R'

You can try out the other tools and see how they behave.
For more info, check out the source code

https://github.com/wch/r-source/blob/trunk/src/gnuwin32/front-ends
https://github.com/wch/r-source/blob/trunk/src/unix/Rscript.c

This question has some good info as well

R.exe, Rcmd.exe, Rscript.exe and Rterm.exe: what's the difference?

