diff --git a/dev/pkgdown.yml b/dev/pkgdown.yml index 98173261..039c6b43 100644 --- a/dev/pkgdown.yml +++ b/dev/pkgdown.yml @@ -3,7 +3,7 @@ pkgdown: 2.1.1 pkgdown_sha: ~ articles: internals: internals.html -last_built: 2025-01-08T19:24Z +last_built: 2025-01-08T19:31Z urls: reference: http://processx.r-lib.org/reference article: http://processx.r-lib.org/articles diff --git a/dev/reference/process.html b/dev/reference/process.html index c9c85b75..3b3e6cff 100644 --- a/dev/reference/process.html +++ b/dev/reference/process.html @@ -1006,7 +1006,7 @@

Examplesp$is_alive() #> [1] TRUE p -#> PROCESS 'sleep', running, pid 6302. +#> PROCESS 'sleep', running, pid 6366. p$kill() #> [1] TRUE p$is_alive() diff --git a/dev/reference/run.html b/dev/reference/run.html index b1e8fb1f..b7808932 100644 --- a/dev/reference/run.html +++ b/dev/reference/run.html @@ -297,7 +297,7 @@

Examples#> system.time(run("sleep", "10", timeout = 1, error_on_status = FALSE)) #> user system elapsed -#> 0.004 0.019 0.258 +#> 0.003 0.014 0.158 system.time( run( "sh", c("-c", "for i in 1 2 3 4 5; do echo $i; sleep 1; done"), @@ -305,7 +305,7 @@

Examples ) ) #> user system elapsed -#> 0.005 0.010 1.254 +#> 0.002 0.012 1.160 if (FALSE) { # This works on Windows systems, if the ping command is available run("ping", c("-n", "1", "127.0.0.1")) diff --git a/dev/search.json b/dev/search.json index 72b218f5..d4374513 100644 --- a/dev/search.json +++ b/dev/search.json @@ -1 +1 @@ -[{"path":[]},{"path":"http://processx.r-lib.org/dev/CODE_OF_CONDUCT.html","id":"our-pledge","dir":"","previous_headings":"","what":"Our Pledge","title":"Contributor Covenant Code of Conduct","text":"members, contributors, leaders pledge make participation community harassment-free experience everyone, regardless age, body size, visible invisible disability, ethnicity, sex characteristics, gender identity expression, level experience, education, socio-economic status, nationality, personal appearance, race, caste, color, religion, sexual identity orientation. pledge act interact ways contribute open, welcoming, diverse, inclusive, healthy community.","code":""},{"path":"http://processx.r-lib.org/dev/CODE_OF_CONDUCT.html","id":"our-standards","dir":"","previous_headings":"","what":"Our Standards","title":"Contributor Covenant Code of Conduct","text":"Examples behavior contributes positive environment community include: Demonstrating empathy kindness toward people respectful differing opinions, viewpoints, experiences Giving gracefully accepting constructive feedback Accepting responsibility apologizing affected mistakes, learning experience Focusing best just us individuals, overall community Examples unacceptable behavior include: use sexualized language imagery, sexual attention advances kind Trolling, insulting derogatory comments, personal political attacks Public private harassment Publishing others’ private information, physical email address, without explicit permission conduct reasonably considered inappropriate professional setting","code":""},{"path":"http://processx.r-lib.org/dev/CODE_OF_CONDUCT.html","id":"enforcement-responsibilities","dir":"","previous_headings":"","what":"Enforcement Responsibilities","title":"Contributor Covenant Code of Conduct","text":"Community leaders responsible clarifying enforcing standards acceptable behavior take appropriate fair corrective action response behavior deem inappropriate, threatening, offensive, harmful. Community leaders right responsibility remove, edit, reject comments, commits, code, wiki edits, issues, contributions aligned Code Conduct, communicate reasons moderation decisions appropriate.","code":""},{"path":"http://processx.r-lib.org/dev/CODE_OF_CONDUCT.html","id":"scope","dir":"","previous_headings":"","what":"Scope","title":"Contributor Covenant Code of Conduct","text":"Code Conduct applies within community spaces, also applies individual officially representing community public spaces. Examples representing community include using official e-mail address, posting via official social media account, acting appointed representative online offline event.","code":""},{"path":"http://processx.r-lib.org/dev/CODE_OF_CONDUCT.html","id":"enforcement","dir":"","previous_headings":"","what":"Enforcement","title":"Contributor Covenant Code of Conduct","text":"Instances abusive, harassing, otherwise unacceptable behavior may reported community leaders responsible enforcement codeofconduct@posit.co. complaints reviewed investigated promptly fairly. community leaders obligated respect privacy security reporter incident.","code":""},{"path":"http://processx.r-lib.org/dev/CODE_OF_CONDUCT.html","id":"enforcement-guidelines","dir":"","previous_headings":"","what":"Enforcement Guidelines","title":"Contributor Covenant Code of Conduct","text":"Community leaders follow Community Impact Guidelines determining consequences action deem violation Code Conduct:","code":""},{"path":"http://processx.r-lib.org/dev/CODE_OF_CONDUCT.html","id":"id_1-correction","dir":"","previous_headings":"Enforcement Guidelines","what":"1. Correction","title":"Contributor Covenant Code of Conduct","text":"Community Impact: Use inappropriate language behavior deemed unprofessional unwelcome community. Consequence: private, written warning community leaders, providing clarity around nature violation explanation behavior inappropriate. public apology may requested.","code":""},{"path":"http://processx.r-lib.org/dev/CODE_OF_CONDUCT.html","id":"id_2-warning","dir":"","previous_headings":"Enforcement Guidelines","what":"2. Warning","title":"Contributor Covenant Code of Conduct","text":"Community Impact: violation single incident series actions. Consequence: warning consequences continued behavior. interaction people involved, including unsolicited interaction enforcing Code Conduct, specified period time. includes avoiding interactions community spaces well external channels like social media. Violating terms may lead temporary permanent ban.","code":""},{"path":"http://processx.r-lib.org/dev/CODE_OF_CONDUCT.html","id":"id_3-temporary-ban","dir":"","previous_headings":"Enforcement Guidelines","what":"3. Temporary Ban","title":"Contributor Covenant Code of Conduct","text":"Community Impact: serious violation community standards, including sustained inappropriate behavior. Consequence: temporary ban sort interaction public communication community specified period time. public private interaction people involved, including unsolicited interaction enforcing Code Conduct, allowed period. Violating terms may lead permanent ban.","code":""},{"path":"http://processx.r-lib.org/dev/CODE_OF_CONDUCT.html","id":"id_4-permanent-ban","dir":"","previous_headings":"Enforcement Guidelines","what":"4. Permanent Ban","title":"Contributor Covenant Code of Conduct","text":"Community Impact: Demonstrating pattern violation community standards, including sustained inappropriate behavior, harassment individual, aggression toward disparagement classes individuals. Consequence: permanent ban sort public interaction within community.","code":""},{"path":"http://processx.r-lib.org/dev/CODE_OF_CONDUCT.html","id":"attribution","dir":"","previous_headings":"","what":"Attribution","title":"Contributor Covenant Code of Conduct","text":"Code Conduct adapted Contributor Covenant, version 2.1, available https://www.contributor-covenant.org/version/2/1/code_of_conduct.html. Community Impact Guidelines inspired [Mozilla’s code conduct enforcement ladder][https://github.com/mozilla/inclusion]. answers common questions code conduct, see FAQ https://www.contributor-covenant.org/faq. Translations available https://www.contributor-covenant.org/translations.","code":""},{"path":"http://processx.r-lib.org/dev/LICENSE.html","id":null,"dir":"","previous_headings":"","what":"MIT License","title":"MIT License","text":"Copyright (c) 2023 processx authors Permission hereby granted, free charge, person obtaining copy software associated documentation files (“Software”), deal Software without restriction, including without limitation rights use, copy, modify, merge, publish, distribute, sublicense, /sell copies Software, permit persons Software furnished , subject following conditions: copyright notice permission notice shall included copies substantial portions Software. SOFTWARE PROVIDED “”, WITHOUT WARRANTY KIND, EXPRESS IMPLIED, INCLUDING LIMITED WARRANTIES MERCHANTABILITY, FITNESS PARTICULAR PURPOSE NONINFRINGEMENT. EVENT SHALL AUTHORS COPYRIGHT HOLDERS LIABLE CLAIM, DAMAGES LIABILITY, WHETHER ACTION CONTRACT, TORT OTHERWISE, ARISING , CONNECTION SOFTWARE USE DEALINGS SOFTWARE.","code":""},{"path":[]},{"path":"http://processx.r-lib.org/dev/articles/internals.html","id":"unix-fifos","dir":"Articles","previous_headings":"FIFOs","what":"Unix FIFOs","title":"processx internals","text":"Unix FIFO interprocess communication device star-topology. (’s right, FIFO can multiple readers writers.) entry file system, although time data FIFO never written disk. Unix FIFO operations: Creating FIFO file system. mkfifo(2) system call. Opening FIFO. open(2). Polling FIFO. use normal poll(2) everything else. Reading FIFO. read(2). Writing FIFO. write(2) friends. Closing FIFO. close(2).","code":""},{"path":"http://processx.r-lib.org/dev/articles/internals.html","id":"blocking-vs-non-blocking-mode","dir":"Articles","previous_headings":"FIFOs","what":"Blocking vs Non-blocking mode","title":"processx internals","text":"processx functions support opening FIFO blocking non-blocking mode. Blocking mode useful open() block side FIFO open()-d least one process. cumbersome ensure can often lead deadlocks. E.g. process fails start connect FIFO, block fovever. Blocking processx FIFOs tested well, unless noted otherwise document non-blocking FIFOs.","code":""},{"path":"http://processx.r-lib.org/dev/articles/internals.html","id":"processxs-fifos-on-unix","dir":"Articles","previous_headings":"FIFOs","what":"processx’s FIFOs on Unix","title":"processx internals","text":"conn_create_fifo() first creates FIFO mkfifo(2) (1 ) opens open(2) (2 ). read = TRUE reader end (reader end, really), write = TRUE writer. writer end, need open non-blocking FIFOs read-write, otherwise open() fails FIFO reader. Weird, Unix. Even weirder, according POSIX, opening FIFO read-write mode undefined behavior. Linux documented behavior O_RDWR succeeds even reader (well, now). Apparently, also bevarios macOS. Many people say internet, standard behavior Unix systems. conn_connect_fifo() connects existing FIFO using open(2) (2 ). (Created processx .) Just like conn_create_fifo() opens FIFO read-write mode instead write-mode. helps situations FIFO file exists reader connected (yet). Unix conn_connect_fifo() fails FIFO file exist, permissions open specified mode. rest operations (3-6 ) usual processx connection operations, nothing special FIFO connections opened.","code":""},{"path":"http://processx.r-lib.org/dev/articles/internals.html","id":"emulating-fifos-with-named-pipes-on-windows","dir":"Articles","previous_headings":"FIFOs","what":"Emulating FIFOs with named pipes on Windows","title":"processx internals","text":"Windows quite equivalent FIFOs, can reasonably emulate named pipes. conn_create_fifo() creates named pipe CreateNamedPipeA() specified name. corresponds creating FIFO opening (1-2 ). conn_connect_fifo() opens named pipe, like regular file, CreateFileA() (2 ). opened, FIFOs work like regular connections. Well, mostly. See notes known platform differences !","code":""},{"path":[]},{"path":"http://processx.r-lib.org/dev/articles/internals.html","id":"how-to-check-if-the-other-write-end-of-the-fifo-is-connected","dir":"Articles","previous_headings":"FIFOs > How-to","what":"How to check if the other write-end of the FIFO is connected?","title":"processx internals","text":"read end, use poll() see data FIFO. way know currently end connects, writes data, poll() return ready .","code":""},{"path":"http://processx.r-lib.org/dev/articles/internals.html","id":"how-to-check-if-the-other-read-end-of-the-fifo-is-connected","dir":"Articles","previous_headings":"FIFOs > How-to","what":"How to check if the other read-end of the FIFO is connected?","title":"processx internals","text":"write end, unfortunately easy way make sure end connected. can try write FIFO, Unix might succeed, Windows might fail. need make sure reader end, ’ll need another FIFO opposite direction, reader can send message connected. (way communicate .) admittedly great, make much difficult use FIFOs.","code":""},{"path":"http://processx.r-lib.org/dev/articles/internals.html","id":"how-to-check-for-end-of-fifo","dir":"Articles","previous_headings":"FIFOs > How-to","what":"How to check for end-of-FIFO?","title":"processx internals","text":"usual. non-blocking read returns zero bytes data writers connected FIFO. Unix maybe writers later, processx care . connection set EOF, EOF. conn_is_incomplete() returns FALSE EOF set. (usual, makes sense check read().","code":""},{"path":"http://processx.r-lib.org/dev/articles/internals.html","id":"how-to-communicate-with-another-process","dir":"Articles","previous_headings":"FIFOs > How-to","what":"How to communicate with another process?","title":"processx internals","text":"Create FIFO conn_create_fifo() pass name FIFO (can use conn_file_name() program. piece text, can pass argument. (watch special characters, especially Windows. best use processx avoid system.) program can open FIFO (reading writing) regular file open(), fopen(), CreateFile(), etc. can open blocking non-blocking mode, needed. need bidirectional communication, use two FIFOs.","code":""},{"path":"http://processx.r-lib.org/dev/articles/internals.html","id":"platform-differences-and-portable-code","dir":"Articles","previous_headings":"FIFOs","what":"Platform differences and portable code","title":"processx internals","text":"See also “Known issues” . connect one reader one writer FIFO. fine Unix, pretty cool, actually, fail Windows. Remember zero readers writers FIFO, end signal EOF next read (poll!) operation. conn_read_*() fail Windows end FIFO connected. Always use poll() first read returns ready. poll() return ready end FIFO connected. conn_write() may fail (Windows) end FIFO connected yet also writers. (always happen, e.g. opened FIFO read-write mode first place!) prepared every conn_write() call can fail. usual conn_write() might able write data pipe/FIFO buffer full, return un-written raw() data. Make sure check return value conn_write(). poll() FIFO can return ready data next conn_read_*(), least Windows. first poll() (Windows) need start asynchronous operation waiting end pipe connect. returns, poll() signal ready, might data read just yet.","code":""},{"path":"http://processx.r-lib.org/dev/articles/internals.html","id":"known-issues","dir":"Articles","previous_headings":"FIFOs","what":"Known issues","title":"processx internals","text":"poll() FIFO might return writer end (writers) close FIFO. poll() return ready read operation, writer closed end. seems macOS bug, really bad. happens least macOS 12.3.1, happen Ubuntu 20.04. Non-ASCII file names pipe name currently issue. (Just like non-ASCII file name conn_create_file() !) fix . Encodings pipe traffic little tested. also fix .","code":""},{"path":"http://processx.r-lib.org/dev/articles/internals.html","id":"links","dir":"Articles","previous_headings":"FIFOs","what":"Links","title":"processx internals","text":"Linux fifo(7) manual page Windows CreateNamedPipeA() manual page","code":""},{"path":[]},{"path":"http://processx.r-lib.org/dev/articles/internals.html","id":"introduction","dir":"Articles","previous_headings":"Unix Domain Sockets","what":"Introduction","title":"processx internals","text":"processx functions perform IPC (inter process communication) processes running machine, using Unix domain sockets. Windows uses named pipes emulate Unix domain sockets, much possible. Unix domain sockets solve many issues FIFOs (processx FIFOs FIFOs general) , suggest use sockets instead FIFOs can.","code":""},{"path":"http://processx.r-lib.org/dev/articles/internals.html","id":"api","dir":"Articles","previous_headings":"Unix Domain Sockets","what":"API","title":"processx internals","text":"processx Unix sockets always bi-directional. conn_create_unix_socket() creates server side socket. conn_connect_unix_socket() creates client side connects server socket. call block, returns, server side accepted connection yet, probably. can still use client socket reading writing, see . can use poll() wait client connect server. client available, poll() returns \"connect\" . client available, call conn_accept_unix_socket() accept . accepting client, can send messages conn_write() read messages conn_read_chars() conn_read_lines() general use server socket read-write processx connection. server call conn_read_*() conn_write() accepting connection, calls error. client can call conn_read_*() conn_write() soon connected. Reading functions return data, conn_write() succeed, internal buffer gets full. (server accepts connection starts reading data buffer). can also use poll() wait incoming data. poll() uses read-side connections, server client. currently way poll write-sides. processx Unix socket connections non-blocking. conn_create_unix_socket(), conn_connect_unix_socket(), conn_accept_unix_socket() non-blocking well. conn_unix_socket_state() return current state socket: listen server socket calling conn_accept_unix_socket() connected_server server socket accepted client connected_client connected client close() closes socket. (read-end write-end.)","code":""},{"path":"http://processx.r-lib.org/dev/articles/internals.html","id":"file-names","dir":"Articles","previous_headings":"Unix Domain Sockets","what":"File names","title":"processx internals","text":"Unix, socket entry file system. default created R temporary directory. Windows, use named pipe emulate socket. user can specify name pipe, random name used \\\\?\\pipe\\ namespace. specify pipe name Windows, starts string processx uses . can use conn_file_name() query full path socket Unix, full name pipe Windows.","code":""},{"path":[]},{"path":"http://processx.r-lib.org/dev/articles/internals.html","id":"how-to-check-if-the-other-end-of-the-socket-is-connected","dir":"Articles","previous_headings":"Unix Domain Sockets > How-to","what":"How to check if the other end of the socket is connected?","title":"processx internals","text":"server socket can poll() client connection. client can assume connected, needs handle case conn_write() write data. (usual every non-blocking processx connection.)","code":""},{"path":"http://processx.r-lib.org/dev/articles/internals.html","id":"how-to-check-for-the-end-of-the-connection","dir":"Articles","previous_headings":"Unix Domain Sockets > How-to","what":"How to check for the end of the connection?","title":"processx internals","text":"usual. poll() return ready end closes connection. can call conn_is_incomplete() right read() see end closed connection. conn_write() error side closed connection.","code":""},{"path":"http://processx.r-lib.org/dev/articles/internals.html","id":"how-to-communicate-with-another-process-1","dir":"Articles","previous_headings":"Unix Domain Sockets > How-to","what":"How to communicate with another process?","title":"processx internals","text":"Pass socket (pipe) name . E.g. can pass command line argument. Note, however passing special file name named pipe might work older Windows systems, might want pass last component path, append \\\\?\\pipe\\ process. See sock.c src/tools example. process R process can load processx, can use processx socket functions connect socket communicate. process R process, load processx, can include include/processx/unix-socket.{c,h} files project connect socket communicate. (write C/C++ code based .) Include .c file exactly one compilation unit program, include .h file others. files portable, blocking Unix socket implementation, simple API: functions blocking, except last one, return -1 error, set errno Unix, can use GetLastError() Windows. can also use processx_socket_error_message() query system error message portable way. function returns pointer error message static buffer, copy need . Note also thread-safe. R package can use unix-socket.{c,h} via LinkingTo entry DESCRIPTION, need specify write similarly .c file:","code":"int processx_socket_connect(const char *filename, processx_socket_t *pxsocket); ssize_t processx_socket_read(processx_socket_t *pxsocket, void *buf, size_t nbyte); ssize_t processx_socket_write(processx_socket_t *pxsocket, void *buf, size_t nbyte); int processx_socket_close(processx_socket_t *pxsocket); const char* processx_socket_error_message(); LinkingTo: processx #include #include "},{"path":"http://processx.r-lib.org/dev/articles/internals.html","id":"known-issues-1","dir":"Articles","previous_headings":"Unix Domain Sockets","what":"Known issues","title":"processx internals","text":"Non-ASCII socket file names pipe name currently issue. (Just like non-ASCII file name conn_create_file() !) Encodings traffic little tested.","code":""},{"path":"http://processx.r-lib.org/dev/authors.html","id":null,"dir":"","previous_headings":"","what":"Authors","title":"Authors and Citation","text":"Gábor Csárdi. Author, maintainer, copyright holder. Winston Chang. Author. . Copyright holder, funder. Ascent Digital Services. Copyright holder, funder.","code":""},{"path":"http://processx.r-lib.org/dev/authors.html","id":"citation","dir":"","previous_headings":"","what":"Citation","title":"Authors and Citation","text":"Csárdi G, Chang W (2025). processx: Execute Control System Processes. R package version 3.8.4.9000, https://github.com/r-lib/processx, https://processx.r-lib.org.","code":"@Manual{, title = {processx: Execute and Control System Processes}, author = {Gábor Csárdi and Winston Chang}, year = {2025}, note = {R package version 3.8.4.9000, https://github.com/r-lib/processx}, url = {https://processx.r-lib.org}, }"},{"path":"http://processx.r-lib.org/dev/index.html","id":"processx","dir":"","previous_headings":"","what":"Execute and Control System Processes","title":"Execute and Control System Processes","text":"Execute Control System Processes Tools run system processes background, read standard output error kill . processx can poll standard output error single process, multiple processes, using operating system’s polling waiting facilities, timeout. Features Installation Errors Showing output Spinner Callbacks /O Starting processes Killing process Standard output error End output Polling standard output error Polling multiple processes Waiting process Exit statuses Mixing processx parallel base R package Errors Related tools Code Conduct License","code":""},{"path":"http://processx.r-lib.org/dev/index.html","id":"features","dir":"","previous_headings":"","what":"Features","title":"Execute and Control System Processes","text":"Start system processes background find process id. Read standard output error, using non-blocking connections Poll standard output error connections single process multiple processes. Write standard input background processes. Check background process running. Wait background process, multiple processes, timeout. Get exit status background process, already finished. Kill background processes. Kill background process, associated object garbage collected. Kill background processes child processes. Works Linux, macOS Windows. Lightweight, depends also lightweight R6 ps packages.","code":""},{"path":"http://processx.r-lib.org/dev/index.html","id":"installation","dir":"","previous_headings":"","what":"Installation","title":"Execute and Control System Processes","text":"Install stable version CRAN: need development version, install GitHub:","code":"install.packages(\"processx\") pak::pak(\"r-lib/processx\")"},{"path":"http://processx.r-lib.org/dev/index.html","id":"usage","dir":"","previous_headings":"","what":"Usage","title":"Execute and Control System Processes","text":"Note: following external commands usually present macOS Linux systems, necessarily Windows. also use px command line tool (px.exe Windows), simple program can produce output stdout stderr, specified timings.","code":"library(processx) px <- paste0( system.file(package = \"processx\", \"bin\", \"px\"), system.file(package = \"processx\", \"bin\", .Platform$r_arch, \"px.exe\") ) px #> [1] \"/Users/gaborcsardi/Library/R/arm64/4.2/library/processx/bin/px\""},{"path":"http://processx.r-lib.org/dev/index.html","id":"running-an-external-process","dir":"","previous_headings":"Usage","what":"Running an external process","title":"Execute and Control System Processes","text":"run() function runs external command. requires single command, character vector arguments. don’t need quote command arguments, passed directly operating system, without intermediate shell. Short summary px binary using extensively : Note: version 3.0.1, processx let specify full shell command line, involves starting grandchild process child process, difficult clean grandchild process child process killed. user can still start shell (sh cmd.exe) directly course, proper cleanup user’s responsibility.","code":"run(\"echo\", \"Hello R!\") #> $status #> [1] 0 #> #> $stdout #> [1] \"Hello R!\\n\" #> #> $stderr #> [1] \"\" #> #> $timeout #> [1] FALSE result <- run(px, \"--help\", echo = TRUE) #> Usage: px [command arg] [command arg] ... #> #> Commands: #> sleep -- sleep for a number os seconds #> out -- print string to stdout #> err -- print string to stderr #> outln -- print string to stdout, add newline #> errln -- print string to stderr, add newline #> errflush -- flush stderr stream #> cat -- print file to stdout #> return -- return with exitcode #> writefile -- write to file #> write -- write to file descriptor #> echo -- echo from fd to another fd #> getenv -- environment variable to stdout"},{"path":"http://processx.r-lib.org/dev/index.html","id":"errors","dir":"","previous_headings":"Usage > Running an external process","what":"Errors","title":"Execute and Control System Processes","text":"default run() throws error process exits non-zero status code. avoid , specify error_on_status = FALSE:","code":"run(px, c(\"out\", \"oh no!\", \"return\", \"2\"), error_on_status = FALSE) #> $status #> [1] 2 #> #> $stdout #> [1] \"oh no!\" #> #> $stderr #> [1] \"\" #> #> $timeout #> [1] FALSE"},{"path":"http://processx.r-lib.org/dev/index.html","id":"showing-output","dir":"","previous_headings":"Usage > Running an external process","what":"Showing output","title":"Execute and Control System Processes","text":"show output process screen, use echo argument. Note order stdout stderr lines may incorrect, coming two different connections. terminal support ANSI colors, standard error output shown red. standard output error still included result run() call: Note run() different system(), always shows output process R’s proper standard output, instead writing terminal directly. means example can capture output capture.output() use sink(), etc.:","code":"result <- run(px, c(\"outln\", \"out\", \"errln\", \"err\", \"outln\", \"out again\"), echo = TRUE) #> out #> out again #> err result #> $status #> [1] 0 #> #> $stdout #> [1] \"out\\nout again\\n\" #> #> $stderr #> [1] \"err\\n\" #> #> $timeout #> [1] FALSE out1 <- capture.output(r1 <- system(\"ls\")) out2 <- capture.output(r2 <- run(\"ls\", echo = TRUE)) out1 #> character(0) out2 #> [1] \"CODE_OF_CONDUCT.md\" \"DESCRIPTION\" \"LICENSE\" #> [4] \"LICENSE.md\" \"Makefile\" \"NAMESPACE\" #> [7] \"NEWS.md\" \"R\" \"README.Rmd\" #> [10] \"README.md\" \"_pkgdown.yml\" \"codecov.yml\" #> [13] \"inst\" \"man\" \"processx.Rproj\" #> [16] \"src\" \"tests\""},{"path":"http://processx.r-lib.org/dev/index.html","id":"spinner","dir":"","previous_headings":"Usage > Running an external process","what":"Spinner","title":"Execute and Control System Processes","text":"spinner option run() puts calming spinner terminal background program running. spinner always shown first character last line, can make work nicely regular output background process like. E.g. try R terminal:","code":"result <- run(px, c(\"out\", \" foo\", \"sleep\", \"1\", \"out\", \"\\r bar\", \"sleep\", \"1\", \"out\", \"\\rX foobar\\n\"), echo = TRUE, spinner = TRUE)"},{"path":"http://processx.r-lib.org/dev/index.html","id":"callbacks-for-io","dir":"","previous_headings":"Usage > Running an external process","what":"Callbacks for I/O","title":"Execute and Control System Processes","text":"run() can call R function line standard output error process, just supply stdout_line_callback stderr_line_callback arguments. callback functions take two arguments, first one character scalar, output line. second one process object represents background process. (See process objects.) can manipulate object callback, want. example can kill response error text standard output: Keep mind, R callback running, background process stopped, also running. previous example, whether still printed depends scheduling R process background process OS. Typically, printed, R callback takes run. addition line-oriented callbacks, stdout_callback stderr_callback arguments can specify callback functions called output chunks instead single lines. chunk may contain multiple lines (separated \\n \\r\\n), even incomplete lines.","code":"cb <- function(line, proc) { cat(\"Got:\", line, \"\\n\") if (line == \"done\") proc$kill() } result <- run(px, c(\"outln\", \"this\", \"outln\", \"that\", \"outln\", \"done\", \"outln\", \"still here\", \"sleep\", \"10\", \"outln\", \"dead by now\"), stdout_line_callback = cb, error_on_status = FALSE, ) #> Got: this #> Got: that #> Got: done #> Got: still here result #> $status #> [1] -9 #> #> $stdout #> [1] \"this\\nthat\\ndone\\nstill here\\n\" #> #> $stderr #> [1] \"\" #> #> $timeout #> [1] FALSE"},{"path":"http://processx.r-lib.org/dev/index.html","id":"managing-external-processes","dir":"","previous_headings":"Usage","what":"Managing external processes","title":"Execute and Control System Processes","text":"need better control possibly multiple background processes, can use R6 process class directly.","code":""},{"path":"http://processx.r-lib.org/dev/index.html","id":"starting-processes","dir":"","previous_headings":"Usage > Managing external processes","what":"Starting processes","title":"Execute and Control System Processes","text":"start new background process, create new instance process class.","code":"p <- process$new(\"sleep\", \"20\")"},{"path":"http://processx.r-lib.org/dev/index.html","id":"killing-a-process","dir":"","previous_headings":"Usage > Managing external processes","what":"Killing a process","title":"Execute and Control System Processes","text":"process can killed via kill() method. Note processes finalized (killed) automatically corresponding process object goes scope, soon object garbage collected R: , direct call garbage collector kills sleep process well. See cleanup option want avoid behavior.","code":"p$is_alive() #> [1] TRUE p$kill() #> [1] TRUE p$is_alive() #> [1] FALSE p <- process$new(\"sleep\", \"20\") rm(p) invisible(gc())"},{"path":"http://processx.r-lib.org/dev/index.html","id":"standard-output-and-error","dir":"","previous_headings":"Usage > Managing external processes","what":"Standard output and error","title":"Execute and Control System Processes","text":"default standard output error processes ignored. can set stdout stderr constructor arguments file name, redirected , \"|\", processx creates connections . (Note starting processx 3.0.0 connections regular R connections, public R connection API retroactively removed R.) read_output_lines() read_error_lines() methods can used read complete lines standard output error connections. work similarly readLines() base R function. Note, connections buffer, can fill , R read output, process stop, R reads connection buffer freed. Always make sure read standard output /error pipes, otherwise background process stop running! don’t need standard output error , can also close , like : Note connections used reading output error streams non-blocking, read functions return immediately, even text read . want make sure data available read, need poll, see .","code":"close(p$get_output_connection()) close(p$get_error_connection()) p <- process$new(px, c(\"sleep\", \"1\", \"outln\", \"foo\", \"errln\", \"bar\", \"outln\", \"foobar\"), stdout = \"|\", stderr = \"|\") p$read_output_lines() #> character(0) p$read_error_lines() #> character(0)"},{"path":"http://processx.r-lib.org/dev/index.html","id":"end-of-output","dir":"","previous_headings":"Usage > Managing external processes","what":"End of output","title":"Execute and Control System Processes","text":"standard R way query end stream non-blocking connection, use isIncomplete() function. read attempt, function returns FALSE connection surely data. (read attempt returns data, isIncomplete() returns TRUE, connection might deliver data future. is_incomplete_output() is_incomplete_error() functions work similarly process objects.","code":""},{"path":"http://processx.r-lib.org/dev/index.html","id":"polling-the-standard-output-and-error","dir":"","previous_headings":"Usage > Managing external processes","what":"Polling the standard output and error","title":"Execute and Control System Processes","text":"poll_io() method waits data standard output /error process. return following events happen: data available standard output process (assuming connection standard output). data available standard error process (assuming connection standard error). process finished standard output /error connections closed end. specified timeout period expired. example following code waits second output.","code":"p <- process$new(px, c(\"sleep\", \"1\", \"outln\", \"kuku\"), stdout = \"|\") ## No output yet p$read_output_lines() #> character(0) ## Wait at most 5 sec p$poll_io(5000) #> output error process #> \"ready\" \"nopipe\" \"nopipe\" ## There is output now p$read_output_lines() #> [1] \"kuku\""},{"path":"http://processx.r-lib.org/dev/index.html","id":"polling-multiple-processes","dir":"","previous_headings":"Usage > Managing external processes","what":"Polling multiple processes","title":"Execute and Control System Processes","text":"need manage multiple background processes, need wait output , processx defines poll() function just . similar poll_io() method, takes multiple process objects, returns soon one data standard output error, timeout expires. example:","code":"p1 <- process$new(px, c(\"sleep\", \"1\", \"outln\", \"output\"), stdout = \"|\") p2 <- process$new(px, c(\"sleep\", \"2\", \"errln\", \"error\"), stderr = \"|\") ## After 100ms no output yet poll(list(p1 = p1, p2 = p2), 100) #> $p1 #> output error process #> \"timeout\" \"nopipe\" \"nopipe\" #> #> $p2 #> output error process #> \"nopipe\" \"timeout\" \"nopipe\" ## But now we surely have something poll(list(p1 = p1, p2 = p2), 1000) #> $p1 #> output error process #> \"ready\" \"nopipe\" \"nopipe\" #> #> $p2 #> output error process #> \"nopipe\" \"silent\" \"nopipe\" p1$read_output_lines() #> [1] \"output\" ## Done with p1 close(p1$get_output_connection()) #> NULL ## The second process should have data on stderr soonish poll(list(p1 = p1, p2 = p2), 5000) #> $p1 #> output error process #> \"closed\" \"nopipe\" \"nopipe\" #> #> $p2 #> output error process #> \"nopipe\" \"ready\" \"nopipe\" p2$read_error_lines() #> [1] \"error\""},{"path":"http://processx.r-lib.org/dev/index.html","id":"waiting-on-a-process","dir":"","previous_headings":"Usage > Managing external processes","what":"Waiting on a process","title":"Execute and Control System Processes","text":"seen , is_alive() checks process running. wait() method can used wait finished (specified timeout expires).. E.g. following code wait() needs wait 2 seconds sleep px command finish. safe call wait() multiple times:","code":"p <- process$new(px, c(\"sleep\", \"2\")) p$is_alive() #> [1] TRUE Sys.time() #> [1] \"2022-06-10 13:57:49 CEST\" p$wait() Sys.time() #> [1] \"2022-06-10 13:57:51 CEST\" p$wait() # already finished!"},{"path":"http://processx.r-lib.org/dev/index.html","id":"exit-statuses","dir":"","previous_headings":"Usage > Managing external processes","what":"Exit statuses","title":"Execute and Control System Processes","text":"process finished, exit status can queried via get_exit_status() method. process still running, method returns NULL.","code":"p <- process$new(px, c(\"sleep\", \"2\")) p$get_exit_status() #> NULL p$wait() p$get_exit_status() #> [1] 0"},{"path":"http://processx.r-lib.org/dev/index.html","id":"mixing-processx-and-the-parallel-base-r-package","dir":"","previous_headings":"Usage > Managing external processes","what":"Mixing processx and the parallel base R package","title":"Execute and Control System Processes","text":"general, mixing processx (via callr ) parallel works fine. use parallel’s ‘fork’ clusters, e.g. via parallel::mcparallel(), might see two issues. One processx able determine exit status processx processes. status read parallel, processx set NA. one parallel might complain clean subprocesses. error, harmless, hold R 10 seconds, parallel gives . work around , can set PROCESSX_NOTIFY_OLD_SIGCHLD environment variable non-empty value, load processx. behavior might default future.","code":""},{"path":"http://processx.r-lib.org/dev/index.html","id":"errors-1","dir":"","previous_headings":"Usage > Managing external processes","what":"Errors","title":"Execute and Control System Processes","text":"Errors typically signalled via non-zero exits statuses. processx constructor fails external program started, deal errors happen program successfully started running.","code":"p <- process$new(\"nonexistant-command-for-sure\") #> Error in c(\"process_initialize(self, private, command, args, stdin, stdout, \", : ! Native call to `processx_exec` failed #> Caused by error in `chain_call(c_processx_exec, command, c(command, args), pty, pty_options, …` at initialize.R:138:3: #> ! cannot start processx process 'nonexistant-command-for-sure' (system error 2, No such file or directory) @unix/processx.c:613 (processx_exec) p2 <- process$new(px, c(\"sleep\", \"1\", \"command-does-not-exist\")) p2$wait() p2$get_exit_status() #> [1] 5"},{"path":"http://processx.r-lib.org/dev/index.html","id":"related-tools","dir":"","previous_headings":"","what":"Related tools","title":"Execute and Control System Processes","text":"ps package can query, list, manipulate system processes (just subprocesses), processx uses internally functionality. can also convert processx::process object ps::ps_handle as_ps_handle() method. callr package uses processx start another R process, run R code , foreground background.","code":""},{"path":"http://processx.r-lib.org/dev/index.html","id":"code-of-conduct","dir":"","previous_headings":"","what":"Code of Conduct","title":"Execute and Control System Processes","text":"Please note processx project released Contributor Code Conduct. contributing project, agree abide terms.","code":""},{"path":"http://processx.r-lib.org/dev/index.html","id":"license","dir":"","previous_headings":"","what":"License","title":"Execute and Control System Processes","text":"MIT © Ascent Digital Services, RStudio, Gábor Csárdi","code":""},{"path":"http://processx.r-lib.org/dev/reference/base64_decode.html","id":null,"dir":"Reference","previous_headings":"","what":"Base64 Encoding and Decoding — base64_decode","title":"Base64 Encoding and Decoding — base64_decode","text":"Base64 Encoding Decoding","code":""},{"path":"http://processx.r-lib.org/dev/reference/base64_decode.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Base64 Encoding and Decoding — base64_decode","text":"","code":"base64_decode(x) base64_encode(x)"},{"path":"http://processx.r-lib.org/dev/reference/base64_decode.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Base64 Encoding and Decoding — base64_decode","text":"x Raw vector encode / decode.","code":""},{"path":"http://processx.r-lib.org/dev/reference/base64_decode.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Base64 Encoding and Decoding — base64_decode","text":"Raw vector, result encoding / decoding.","code":""},{"path":"http://processx.r-lib.org/dev/reference/curl_fds.html","id":null,"dir":"Reference","previous_headings":"","what":"Create a pollable object from a curl multi handle's file descriptors — curl_fds","title":"Create a pollable object from a curl multi handle's file descriptors — curl_fds","text":"Create pollable object curl multi handle's file descriptors","code":""},{"path":"http://processx.r-lib.org/dev/reference/curl_fds.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Create a pollable object from a curl multi handle's file descriptors — curl_fds","text":"","code":"curl_fds(fds)"},{"path":"http://processx.r-lib.org/dev/reference/curl_fds.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Create a pollable object from a curl multi handle's file descriptors — curl_fds","text":"fds list file descriptors, returned curl::multi_fdset().","code":""},{"path":"http://processx.r-lib.org/dev/reference/curl_fds.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Create a pollable object from a curl multi handle's file descriptors — curl_fds","text":"Pollable object, used poll() directly.","code":""},{"path":"http://processx.r-lib.org/dev/reference/default_pty_options.html","id":null,"dir":"Reference","previous_headings":"","what":"Default options for pseudo terminals (ptys) — default_pty_options","title":"Default options for pseudo terminals (ptys) — default_pty_options","text":"Default options pseudo terminals (ptys)","code":""},{"path":"http://processx.r-lib.org/dev/reference/default_pty_options.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Default options for pseudo terminals (ptys) — default_pty_options","text":"","code":"default_pty_options()"},{"path":"http://processx.r-lib.org/dev/reference/default_pty_options.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Default options for pseudo terminals (ptys) — default_pty_options","text":"Named list default values pty options. Options default values: echo whether keep echo terminal. FALSE turns echo . rows (initial) terminal size, number rows. cols (initial) terminal size, number columns.","code":""},{"path":"http://processx.r-lib.org/dev/reference/poll.html","id":null,"dir":"Reference","previous_headings":"","what":"Poll for process I/O or termination — poll","title":"Poll for process I/O or termination — poll","text":"Wait one specified connections processes produce standard output error, terminates, timeout occurs.","code":""},{"path":"http://processx.r-lib.org/dev/reference/poll.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Poll for process I/O or termination — poll","text":"","code":"poll(processes, ms)"},{"path":"http://processx.r-lib.org/dev/reference/poll.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Poll for process I/O or termination — poll","text":"processes list connection objects orprocess objects wait . (can mixed well.) named list, returned list names. simplifies identification processes. ms Integer scalar, timeout polling, milliseconds. Supply -1 infitite timeout, 0 waiting .","code":""},{"path":"http://processx.r-lib.org/dev/reference/poll.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Poll for process I/O or termination — poll","text":"list character vectors length one three. one list element connection/process, order input list. connections result single string scalar. processes character vectors' elements named output, error process. Possible values individual result : nopipe, ready, timeout, closed, silent. See details . process refers poll connection, see poll_connection argument process initializer.","code":""},{"path":"http://processx.r-lib.org/dev/reference/poll.html","id":"explanation-of-the-return-values","dir":"Reference","previous_headings":"","what":"Explanation of the return values","title":"Poll for process I/O or termination — poll","text":"nopipe means stdout stderr process captured. ready means connection stdout stderr process ready read . Note end--file outputs also triggers ready. timeout`: connections processes ready read timeout happened. closed: connection already closed, polling started. silent: connection ready read , another connection .","code":""},{"path":"http://processx.r-lib.org/dev/reference/poll.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Poll for process I/O or termination — poll","text":"","code":"if (FALSE) { # Different commands to run for windows and unix cmd1 <- switch( .Platform$OS.type, \"unix\" = c(\"sh\", \"-c\", \"sleep 1; ls\"), c(\"cmd\", \"/c\", \"ping -n 2 127.0.0.1 && dir /b\") ) cmd2 <- switch( .Platform$OS.type, \"unix\" = c(\"sh\", \"-c\", \"sleep 2; ls 1>&2\"), c(\"cmd\", \"/c\", \"ping -n 2 127.0.0.1 && dir /b 1>&2\") ) ## Run them. p1 writes to stdout, p2 to stderr, after some sleep p1 <- process$new(cmd1[1], cmd1[-1], stdout = \"|\") p2 <- process$new(cmd2[1], cmd2[-1], stderr = \"|\") ## Nothing to read initially poll(list(p1 = p1, p2 = p2), 0) ## Wait until p1 finishes. Now p1 has some output p1$wait() poll(list(p1 = p1, p2 = p2), -1) ## Close p1's connection, p2 will have output on stderr, eventually close(p1$get_output_connection()) poll(list(p1 = p1, p2 = p2), -1) ## Close p2's connection as well, no nothing to poll close(p2$get_error_connection()) poll(list(p1 = p1, p2 = p2), 0) }"},{"path":"http://processx.r-lib.org/dev/reference/process.html","id":null,"dir":"Reference","previous_headings":"","what":"External process — process","title":"External process — process","text":"Managing external processes R trivial, class aims help deficiency. essentially small wrapper around system base R function, return process id started process, set standard output error streams. process id used manage process.","code":""},{"path":"http://processx.r-lib.org/dev/reference/process.html","id":"batch-files","dir":"Reference","previous_headings":"","what":"Batch files","title":"External process — process","text":"Running Windows batch files (.bat .cmd files) may complicated cmd.exe command line parsing rules. example easily whitespace command (path) one arguments. work around limitations need start cmd.exe shell explicitly use call command. example: works even bat_file contains whitespace characters. information , see processx issue: https://github.com/r-lib/processx/issues/301 detailed parsing rules https://docs.microsoft.com/en-us/windows-server/administration/windows-commands/cmd good practical guide https://ss64.com/nt/syntax-esc.html","code":"process$new(\"cmd.exe\", c(\"/c\", \"call\", bat_file, \"arg 1\", \"arg 2\"))"},{"path":"http://processx.r-lib.org/dev/reference/process.html","id":"polling","dir":"Reference","previous_headings":"","what":"Polling","title":"External process — process","text":"poll_io() function polls standard output standard error connections process, timeout. output either , closed (e.g. process exits) poll_io() returns immediately. addition polling single process, poll() function can poll output several processes, returns soon generated output (exited).","code":""},{"path":"http://processx.r-lib.org/dev/reference/process.html","id":"cleaning-up-background-processes","dir":"Reference","previous_headings":"","what":"Cleaning up background processes","title":"External process — process","text":"processx kills processes referenced (cleanup set TRUE), whole subprocess tree (cleanup_tree also set TRUE). cleanup happens references processes object garbage collected. clean earlier, can call kill() kill_tree() method process(es), .exit() expression, error handler: interrupt process_manager() error happens p1 p2 cleaned immediately. connections also closed. happens regular exit.","code":"process_manager <- function() { on.exit({ try(p1$kill(), silent = TRUE) try(p2$kill(), silent = TRUE) }, add = TRUE) p1 <- process$new(\"sleep\", \"3\") p2 <- process$new(\"sleep\", \"10\") p1$wait() p2$wait() } process_manager()"},{"path":[]},{"path":"http://processx.r-lib.org/dev/reference/process.html","id":"public-methods","dir":"Reference","previous_headings":"","what":"Public methods","title":"External process — process","text":"process$new() process$finalize() process$kill() process$kill_tree() process$signal() process$interrupt() process$get_pid() process$is_alive() process$wait() process$get_exit_status() process$format() process$print() process$get_start_time() process$is_supervised() process$supervise() process$read_output() process$read_error() process$read_output_lines() process$read_error_lines() process$is_incomplete_output() process$is_incomplete_error() process$has_input_connection() process$has_output_connection() process$has_error_connection() process$has_poll_connection() process$get_input_connection() process$get_output_connection() process$get_error_connection() process$read_all_output() process$read_all_error() process$read_all_output_lines() process$read_all_error_lines() process$write_input() process$get_input_file() process$get_output_file() process$get_error_file() process$poll_io() process$get_poll_connection() process$get_result() process$as_ps_handle() process$get_name() process$get_exe() process$get_cmdline() process$get_status() process$get_username() process$get_wd() process$get_cpu_times() process$get_memory_info() process$suspend() process$resume()","code":""},{"path":"http://processx.r-lib.org/dev/reference/process.html","id":"method-new-","dir":"Reference","previous_headings":"","what":"Method new()","title":"External process — process","text":"Start new process background, return immediately.","code":""},{"path":"http://processx.r-lib.org/dev/reference/process.html","id":"usage","dir":"Reference","previous_headings":"","what":"Usage","title":"External process — process","text":"","code":"process$new( command = NULL, args = character(), stdin = NULL, stdout = NULL, stderr = NULL, pty = FALSE, pty_options = list(), connections = list(), poll_connection = NULL, env = NULL, cleanup = TRUE, cleanup_tree = FALSE, wd = NULL, echo_cmd = FALSE, supervise = FALSE, windows_verbatim_args = FALSE, windows_hide_window = FALSE, windows_detached_process = !cleanup, encoding = \"\", post_process = NULL )"},{"path":"http://processx.r-lib.org/dev/reference/process.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"External process — process","text":"command Character scalar, command run. Note argument passed shell, tilde-expansion variable substitution performed . quoted base::shQuote(). See base::normalizePath() tilde-expansion. want run .bat .cmd files Windows, make sure read 'Batch files' section . args Character vector, arguments command. passed process , without shell transforming , need escaped. stdin standard input. Possible values: NULL: set null device, .e. standard input provided; file name, use file standard input; \"|\": create (writeable) connection stdin. \"\" (empty string): inherit main R process. main R process standard input stream, e.g. RGui Windows, error thrown. stdout standard output. Possible values: NULL: discard ; string, redirect file. Note specify relative path, relative current working directory, even specify another directory wd argument. (See issue 324.) \"|\": create connection . \"\" (empty string): inherit main R process. main R process standard output stream, e.g. RGui Windows, error thrown. stderr standard error. Possible values: NULL: discard . string, redirect file. Note specify relative path, relative current working directory, even specify another directory wd argument. (See issue 324.) \"|\": create connection . \"2>&1\": redirect connection (.e. pipe file) stdout. \"2>&1\" way keep standard output error correctly interleaved. \"\" (empty string): inherit main R process. main R process standard error stream, e.g. RGui Windows, error thrown. pty Whether create pseudo terminal (pty) background process. currently supported Unix systems, supported Solaris. TRUE, stdin, stdout stderr arguments must NULL. pseudo terminal created, processx create pipes standard input standard output. separate pipe standard error, way distinguish stdout stderr pty. Note standard output connection pty blocking, always poll standard output connection reading using $read_output() method. Also, $read_output_lines() still block complete line available, function always fails process pty. Use $read_output() read ptys. pty_options Unix pseudo terminal options, named list. see default_pty_options() details defaults. connections list processx connections pass child process. experimental feature currently. poll_connection Whether create extra connection process allows polling, even standard input standard output pipes. NULL (default), connection created standard output standard error pipes, connections empty list. poll connection created, can query via p$get_poll_connection() also included response p$poll_io() poll(). numeric file descriptor poll connection comes right stderr (2), connections listed connections. env Environment variables child process. NULL, parent's environment inherited. Windows, many programs function correctly environment variables set, always set HOMEDRIVE, HOMEPATH, LOGONSERVER, PATH, SYSTEMDRIVE, SYSTEMROOT, TEMP, USERDOMAIN, USERNAME, USERPROFILE WINDIR. append new environment variables ones set current process, specify \"current\" env, without name, appended ones names. appended ones can overwrite current ones. cleanup Whether kill process process object garbage collected. cleanup_tree Whether kill process child process tree process object garbage collected. wd Working directory process. must exist. NULL, current working directory used. echo_cmd Whether print command screen running . supervise Whether register process supervisor. TRUE, supervisor ensure process killed R process exits. windows_verbatim_args Whether omit quoting arguments Windows. ignored platforms. windows_hide_window Whether hide application's window Windows. ignored platforms. windows_detached_process Whether use DETACHED_PROCESS flag Windows. TRUE, child process attached console, even parent one. encoding encoding assume stdin, stdout stderr. default encoding current locale used. Note processx always reencodes output stdout stderr streams UTF-8 currently. want read without conversion, platforms, specify \"UTF-8\" encoding. post_process optional function run process finished. Currently runs $get_result() called. run .","code":""},{"path":"http://processx.r-lib.org/dev/reference/process.html","id":"returns","dir":"Reference","previous_headings":"","what":"Returns","title":"External process — process","text":"R6 object representing process.","code":""},{"path":"http://processx.r-lib.org/dev/reference/process.html","id":"method-finalize-","dir":"Reference","previous_headings":"","what":"Method finalize()","title":"External process — process","text":"Cleanup method called process object garbage collected. requested process constructor, eliminates processes process's subprocess tree.","code":""},{"path":"http://processx.r-lib.org/dev/reference/process.html","id":"usage-1","dir":"Reference","previous_headings":"","what":"Usage","title":"External process — process","text":"","code":"process$finalize()"},{"path":"http://processx.r-lib.org/dev/reference/process.html","id":"method-kill-","dir":"Reference","previous_headings":"","what":"Method kill()","title":"External process — process","text":"Terminate process. also terminate child processes, except created new process group (Unix), job object (Windows). returns TRUE process terminated, FALSE (already finished/dead processx tried terminate ).","code":""},{"path":"http://processx.r-lib.org/dev/reference/process.html","id":"usage-2","dir":"Reference","previous_headings":"","what":"Usage","title":"External process — process","text":"","code":"process$kill(grace = 0.1, close_connections = TRUE)"},{"path":"http://processx.r-lib.org/dev/reference/process.html","id":"arguments-1","dir":"Reference","previous_headings":"","what":"Arguments","title":"External process — process","text":"grace Currently used. close_connections Whether close standard input, standard output, standard error connections poll connection, killing process.","code":""},{"path":"http://processx.r-lib.org/dev/reference/process.html","id":"method-kill-tree-","dir":"Reference","previous_headings":"","what":"Method kill_tree()","title":"External process — process","text":"Process tree cleanup. terminates process (still alive), together child (grandchild, etc.) processes. uses ps package, needs installed, ps needs support current platform well. Process tree cleanup works marking process environment variable, inherited child processes. allows finding descendents, even orphaned, .e. connected root tree cleanup process tree . $kill_tree() returns named integer vector process ids killed, names names processes (e.g. \"sleep\", \"notepad.exe\", \"Rterm.exe\", etc.).","code":""},{"path":"http://processx.r-lib.org/dev/reference/process.html","id":"usage-3","dir":"Reference","previous_headings":"","what":"Usage","title":"External process — process","text":"","code":"process$kill_tree(grace = 0.1, close_connections = TRUE)"},{"path":"http://processx.r-lib.org/dev/reference/process.html","id":"arguments-2","dir":"Reference","previous_headings":"","what":"Arguments","title":"External process — process","text":"grace Currently used. close_connections Whether close standard input, standard output, standard error connections poll connection, killing process.","code":""},{"path":"http://processx.r-lib.org/dev/reference/process.html","id":"method-signal-","dir":"Reference","previous_headings":"","what":"Method signal()","title":"External process — process","text":"Send signal process. Windows SIGINT, SIGTERM SIGKILL signals interpreted, special 0 signal. first three kill process. 0 signal returns TRUE process alive, FALSE otherwise. Unix signals supported OS supports, 0 signal well.","code":""},{"path":"http://processx.r-lib.org/dev/reference/process.html","id":"usage-4","dir":"Reference","previous_headings":"","what":"Usage","title":"External process — process","text":"","code":"process$signal(signal)"},{"path":"http://processx.r-lib.org/dev/reference/process.html","id":"arguments-3","dir":"Reference","previous_headings":"","what":"Arguments","title":"External process — process","text":"signal integer scalar, id signal send process. See tools::pskill() list signals.","code":""},{"path":"http://processx.r-lib.org/dev/reference/process.html","id":"method-interrupt-","dir":"Reference","previous_headings":"","what":"Method interrupt()","title":"External process — process","text":"Send interrupt process. Unix SIGINT signal, usually equivalent pressing CTRL+C terminal prompt. Windows, CTRL+BREAK keypress. Applications may catch events. default quit.","code":""},{"path":"http://processx.r-lib.org/dev/reference/process.html","id":"usage-5","dir":"Reference","previous_headings":"","what":"Usage","title":"External process — process","text":"","code":"process$interrupt()"},{"path":"http://processx.r-lib.org/dev/reference/process.html","id":"method-get-pid-","dir":"Reference","previous_headings":"","what":"Method get_pid()","title":"External process — process","text":"Query process id.","code":""},{"path":"http://processx.r-lib.org/dev/reference/process.html","id":"usage-6","dir":"Reference","previous_headings":"","what":"Usage","title":"External process — process","text":"","code":"process$get_pid()"},{"path":"http://processx.r-lib.org/dev/reference/process.html","id":"returns-1","dir":"Reference","previous_headings":"","what":"Returns","title":"External process — process","text":"Integer scalar, process id process.","code":""},{"path":"http://processx.r-lib.org/dev/reference/process.html","id":"method-is-alive-","dir":"Reference","previous_headings":"","what":"Method is_alive()","title":"External process — process","text":"Check process alive.","code":""},{"path":"http://processx.r-lib.org/dev/reference/process.html","id":"usage-7","dir":"Reference","previous_headings":"","what":"Usage","title":"External process — process","text":"","code":"process$is_alive()"},{"path":"http://processx.r-lib.org/dev/reference/process.html","id":"returns-2","dir":"Reference","previous_headings":"","what":"Returns","title":"External process — process","text":"Logical scalar.","code":""},{"path":"http://processx.r-lib.org/dev/reference/process.html","id":"method-wait-","dir":"Reference","previous_headings":"","what":"Method wait()","title":"External process — process","text":"Wait process finishes, timeout happens. Note process never finishes, timeout infinite (default), R never regain control. rare cases, $wait() might take bit longer specified time . happens Unix, another package overwrites processx SIGCHLD signal handler, processx process started. One package parallel, used fork clusters, e.g. parallel::mcparallel().","code":""},{"path":"http://processx.r-lib.org/dev/reference/process.html","id":"usage-8","dir":"Reference","previous_headings":"","what":"Usage","title":"External process — process","text":"","code":"process$wait(timeout = -1)"},{"path":"http://processx.r-lib.org/dev/reference/process.html","id":"arguments-4","dir":"Reference","previous_headings":"","what":"Arguments","title":"External process — process","text":"timeout Timeout milliseconds, wait /O polling.","code":""},{"path":"http://processx.r-lib.org/dev/reference/process.html","id":"returns-3","dir":"Reference","previous_headings":"","what":"Returns","title":"External process — process","text":"returns process , invisibly.","code":""},{"path":"http://processx.r-lib.org/dev/reference/process.html","id":"method-get-exit-status-","dir":"Reference","previous_headings":"","what":"Method get_exit_status()","title":"External process — process","text":"$get_exit_status returns exit code process finished NULL otherwise. Unix, rare cases, exit status might NA. happens another package (R ) overwrites processx SIGCHLD handler, processx process started. cases processx determine real exit status process. One package parallel, used fork clusters, e.g. parallel::mcparallel() function.","code":""},{"path":"http://processx.r-lib.org/dev/reference/process.html","id":"usage-9","dir":"Reference","previous_headings":"","what":"Usage","title":"External process — process","text":"","code":"process$get_exit_status()"},{"path":"http://processx.r-lib.org/dev/reference/process.html","id":"method-format-","dir":"Reference","previous_headings":"","what":"Method format()","title":"External process — process","text":"format(p) p$format() creates string representation process, usually printing.","code":""},{"path":"http://processx.r-lib.org/dev/reference/process.html","id":"usage-10","dir":"Reference","previous_headings":"","what":"Usage","title":"External process — process","text":"","code":"process$format()"},{"path":"http://processx.r-lib.org/dev/reference/process.html","id":"method-print-","dir":"Reference","previous_headings":"","what":"Method print()","title":"External process — process","text":"print(p) p$print() shows information process screen, whether running process id, etc.","code":""},{"path":"http://processx.r-lib.org/dev/reference/process.html","id":"usage-11","dir":"Reference","previous_headings":"","what":"Usage","title":"External process — process","text":"","code":"process$print()"},{"path":"http://processx.r-lib.org/dev/reference/process.html","id":"method-get-start-time-","dir":"Reference","previous_headings":"","what":"Method get_start_time()","title":"External process — process","text":"$get_start_time() returns time process started.","code":""},{"path":"http://processx.r-lib.org/dev/reference/process.html","id":"usage-12","dir":"Reference","previous_headings":"","what":"Usage","title":"External process — process","text":"","code":"process$get_start_time()"},{"path":"http://processx.r-lib.org/dev/reference/process.html","id":"method-is-supervised-","dir":"Reference","previous_headings":"","what":"Method is_supervised()","title":"External process — process","text":"$is_supervised() returns whether process tracked supervisor process.","code":""},{"path":"http://processx.r-lib.org/dev/reference/process.html","id":"usage-13","dir":"Reference","previous_headings":"","what":"Usage","title":"External process — process","text":"","code":"process$is_supervised()"},{"path":"http://processx.r-lib.org/dev/reference/process.html","id":"method-supervise-","dir":"Reference","previous_headings":"","what":"Method supervise()","title":"External process — process","text":"$supervise() passed TRUE, tells supervisor start tracking process. FALSE, tells supervisor stop tracking process. Note even supervisor disabled process, started cleanup = TRUE, process still killed object garbage collected.","code":""},{"path":"http://processx.r-lib.org/dev/reference/process.html","id":"usage-14","dir":"Reference","previous_headings":"","what":"Usage","title":"External process — process","text":"","code":"process$supervise(status)"},{"path":"http://processx.r-lib.org/dev/reference/process.html","id":"arguments-5","dir":"Reference","previous_headings":"","what":"Arguments","title":"External process — process","text":"status Whether turn supervisor process.","code":""},{"path":"http://processx.r-lib.org/dev/reference/process.html","id":"method-read-output-","dir":"Reference","previous_headings":"","what":"Method read_output()","title":"External process — process","text":"$read_output() reads standard output connection process. standard output connection requested, returns error. uses non-blocking text connection. work stdout=\"|\" used. Otherwise, throw error.","code":""},{"path":"http://processx.r-lib.org/dev/reference/process.html","id":"usage-15","dir":"Reference","previous_headings":"","what":"Usage","title":"External process — process","text":"","code":"process$read_output(n = -1)"},{"path":"http://processx.r-lib.org/dev/reference/process.html","id":"arguments-6","dir":"Reference","previous_headings":"","what":"Arguments","title":"External process — process","text":"n Number characters lines read.","code":""},{"path":"http://processx.r-lib.org/dev/reference/process.html","id":"method-read-error-","dir":"Reference","previous_headings":"","what":"Method read_error()","title":"External process — process","text":"$read_error() similar $read_output, reads standard error stream.","code":""},{"path":"http://processx.r-lib.org/dev/reference/process.html","id":"usage-16","dir":"Reference","previous_headings":"","what":"Usage","title":"External process — process","text":"","code":"process$read_error(n = -1)"},{"path":"http://processx.r-lib.org/dev/reference/process.html","id":"arguments-7","dir":"Reference","previous_headings":"","what":"Arguments","title":"External process — process","text":"n Number characters lines read.","code":""},{"path":"http://processx.r-lib.org/dev/reference/process.html","id":"method-read-output-lines-","dir":"Reference","previous_headings":"","what":"Method read_output_lines()","title":"External process — process","text":"$read_output_lines() reads lines standard output connection process. standard output connection requested, returns error. uses non-blocking text connection. work stdout=\"|\" used. Otherwise, throw error.","code":""},{"path":"http://processx.r-lib.org/dev/reference/process.html","id":"usage-17","dir":"Reference","previous_headings":"","what":"Usage","title":"External process — process","text":"","code":"process$read_output_lines(n = -1)"},{"path":"http://processx.r-lib.org/dev/reference/process.html","id":"arguments-8","dir":"Reference","previous_headings":"","what":"Arguments","title":"External process — process","text":"n Number characters lines read.","code":""},{"path":"http://processx.r-lib.org/dev/reference/process.html","id":"method-read-error-lines-","dir":"Reference","previous_headings":"","what":"Method read_error_lines()","title":"External process — process","text":"$read_error_lines() similar $read_output_lines, reads standard error stream.","code":""},{"path":"http://processx.r-lib.org/dev/reference/process.html","id":"usage-18","dir":"Reference","previous_headings":"","what":"Usage","title":"External process — process","text":"","code":"process$read_error_lines(n = -1)"},{"path":"http://processx.r-lib.org/dev/reference/process.html","id":"arguments-9","dir":"Reference","previous_headings":"","what":"Arguments","title":"External process — process","text":"n Number characters lines read.","code":""},{"path":"http://processx.r-lib.org/dev/reference/process.html","id":"method-is-incomplete-output-","dir":"Reference","previous_headings":"","what":"Method is_incomplete_output()","title":"External process — process","text":"$is_incomplete_output() return FALSE end standard output connection closed (probably process exited). return TRUE otherwise.","code":""},{"path":"http://processx.r-lib.org/dev/reference/process.html","id":"usage-19","dir":"Reference","previous_headings":"","what":"Usage","title":"External process — process","text":"","code":"process$is_incomplete_output()"},{"path":"http://processx.r-lib.org/dev/reference/process.html","id":"method-is-incomplete-error-","dir":"Reference","previous_headings":"","what":"Method is_incomplete_error()","title":"External process — process","text":"$is_incomplete_error() return FALSE end standard error connection closed (probably process exited). return TRUE otherwise.","code":""},{"path":"http://processx.r-lib.org/dev/reference/process.html","id":"usage-20","dir":"Reference","previous_headings":"","what":"Usage","title":"External process — process","text":"","code":"process$is_incomplete_error()"},{"path":"http://processx.r-lib.org/dev/reference/process.html","id":"method-has-input-connection-","dir":"Reference","previous_headings":"","what":"Method has_input_connection()","title":"External process — process","text":"$has_input_connection() return TRUE connection object standard input; words, stdout=\"|\". returns FALSE otherwise.","code":""},{"path":"http://processx.r-lib.org/dev/reference/process.html","id":"usage-21","dir":"Reference","previous_headings":"","what":"Usage","title":"External process — process","text":"","code":"process$has_input_connection()"},{"path":"http://processx.r-lib.org/dev/reference/process.html","id":"method-has-output-connection-","dir":"Reference","previous_headings":"","what":"Method has_output_connection()","title":"External process — process","text":"$has_output_connection() returns TRUE connection object standard output; words, stdout=\"|\". returns FALSE otherwise.","code":""},{"path":"http://processx.r-lib.org/dev/reference/process.html","id":"usage-22","dir":"Reference","previous_headings":"","what":"Usage","title":"External process — process","text":"","code":"process$has_output_connection()"},{"path":"http://processx.r-lib.org/dev/reference/process.html","id":"method-has-error-connection-","dir":"Reference","previous_headings":"","what":"Method has_error_connection()","title":"External process — process","text":"$has_error_connection() returns TRUE connection object standard error; words, stderr=\"|\". returns FALSE otherwise.","code":""},{"path":"http://processx.r-lib.org/dev/reference/process.html","id":"usage-23","dir":"Reference","previous_headings":"","what":"Usage","title":"External process — process","text":"","code":"process$has_error_connection()"},{"path":"http://processx.r-lib.org/dev/reference/process.html","id":"method-has-poll-connection-","dir":"Reference","previous_headings":"","what":"Method has_poll_connection()","title":"External process — process","text":"$has_poll_connection() return TRUE poll connection, FALSE otherwise.","code":""},{"path":"http://processx.r-lib.org/dev/reference/process.html","id":"usage-24","dir":"Reference","previous_headings":"","what":"Usage","title":"External process — process","text":"","code":"process$has_poll_connection()"},{"path":"http://processx.r-lib.org/dev/reference/process.html","id":"method-get-input-connection-","dir":"Reference","previous_headings":"","what":"Method get_input_connection()","title":"External process — process","text":"$get_input_connection() returns connection object, standard input stream process.","code":""},{"path":"http://processx.r-lib.org/dev/reference/process.html","id":"usage-25","dir":"Reference","previous_headings":"","what":"Usage","title":"External process — process","text":"","code":"process$get_input_connection()"},{"path":"http://processx.r-lib.org/dev/reference/process.html","id":"method-get-output-connection-","dir":"Reference","previous_headings":"","what":"Method get_output_connection()","title":"External process — process","text":"$get_output_connection() returns connection object, standard output stream process.","code":""},{"path":"http://processx.r-lib.org/dev/reference/process.html","id":"usage-26","dir":"Reference","previous_headings":"","what":"Usage","title":"External process — process","text":"","code":"process$get_output_connection()"},{"path":"http://processx.r-lib.org/dev/reference/process.html","id":"method-get-error-connection-","dir":"Reference","previous_headings":"","what":"Method get_error_connection()","title":"External process — process","text":"$get_error_conneciton() returns connection object, standard error stream process.","code":""},{"path":"http://processx.r-lib.org/dev/reference/process.html","id":"usage-27","dir":"Reference","previous_headings":"","what":"Usage","title":"External process — process","text":"","code":"process$get_error_connection()"},{"path":"http://processx.r-lib.org/dev/reference/process.html","id":"method-read-all-output-","dir":"Reference","previous_headings":"","what":"Method read_all_output()","title":"External process — process","text":"$read_all_output() waits standard output process. return process finished. Note process involves waiting process finish, polling /O potentially several readLines() calls. returns character scalar. return content stdout=\"|\" used. Otherwise, throw error.","code":""},{"path":"http://processx.r-lib.org/dev/reference/process.html","id":"usage-28","dir":"Reference","previous_headings":"","what":"Usage","title":"External process — process","text":"","code":"process$read_all_output()"},{"path":"http://processx.r-lib.org/dev/reference/process.html","id":"method-read-all-error-","dir":"Reference","previous_headings":"","what":"Method read_all_error()","title":"External process — process","text":"$read_all_error() waits standard error process. return process finished. Note process involves waiting process finish, polling /O potentially several readLines() calls. returns character scalar. return content stderr=\"|\" used. Otherwise, throw error.","code":""},{"path":"http://processx.r-lib.org/dev/reference/process.html","id":"usage-29","dir":"Reference","previous_headings":"","what":"Usage","title":"External process — process","text":"","code":"process$read_all_error()"},{"path":"http://processx.r-lib.org/dev/reference/process.html","id":"method-read-all-output-lines-","dir":"Reference","previous_headings":"","what":"Method read_all_output_lines()","title":"External process — process","text":"$read_all_output_lines() waits standard output lines process. return process finished. Note process involves waiting process finish, polling /O potentially several readLines() calls. returns character vector. return content stdout=\"|\" used. Otherwise, throw error.","code":""},{"path":"http://processx.r-lib.org/dev/reference/process.html","id":"usage-30","dir":"Reference","previous_headings":"","what":"Usage","title":"External process — process","text":"","code":"process$read_all_output_lines()"},{"path":"http://processx.r-lib.org/dev/reference/process.html","id":"method-read-all-error-lines-","dir":"Reference","previous_headings":"","what":"Method read_all_error_lines()","title":"External process — process","text":"$read_all_error_lines() waits standard error lines process. return process finished. Note process involves waiting process finish, polling /O potentially several readLines() calls. returns character vector. return content stderr=\"|\" used. Otherwise, throw error.","code":""},{"path":"http://processx.r-lib.org/dev/reference/process.html","id":"usage-31","dir":"Reference","previous_headings":"","what":"Usage","title":"External process — process","text":"","code":"process$read_all_error_lines()"},{"path":"http://processx.r-lib.org/dev/reference/process.html","id":"method-write-input-","dir":"Reference","previous_headings":"","what":"Method write_input()","title":"External process — process","text":"$write_input() writes character vector (separated sep) standard input process. converted specified encoding. operation non-blocking, return, even write fails (write buffer full), suceeds partially (.e. full string written). returns raw vector, contains bytes written. can supply raw vector $write_input() , fully written, return value raw(0) (invisibly).","code":""},{"path":"http://processx.r-lib.org/dev/reference/process.html","id":"usage-32","dir":"Reference","previous_headings":"","what":"Usage","title":"External process — process","text":"","code":"process$write_input(str, sep = \"\\n\")"},{"path":"http://processx.r-lib.org/dev/reference/process.html","id":"arguments-10","dir":"Reference","previous_headings":"","what":"Arguments","title":"External process — process","text":"str Character raw vector write standard input process. character vector marked encoding, converted encoding. sep Separator add str elements character vector. ignored str raw vector.","code":""},{"path":"http://processx.r-lib.org/dev/reference/process.html","id":"returns-4","dir":"Reference","previous_headings":"","what":"Returns","title":"External process — process","text":"Leftover text (raw vector), written.","code":""},{"path":"http://processx.r-lib.org/dev/reference/process.html","id":"method-get-input-file-","dir":"Reference","previous_headings":"","what":"Method get_input_file()","title":"External process — process","text":"$get_input_file() stdin argument filename, returns absolute path file. stdin \"|\" NULL, simply returns value.","code":""},{"path":"http://processx.r-lib.org/dev/reference/process.html","id":"usage-33","dir":"Reference","previous_headings":"","what":"Usage","title":"External process — process","text":"","code":"process$get_input_file()"},{"path":"http://processx.r-lib.org/dev/reference/process.html","id":"method-get-output-file-","dir":"Reference","previous_headings":"","what":"Method get_output_file()","title":"External process — process","text":"$get_output_file() stdout argument filename, returns absolute path file. stdout \"|\" NULL, simply returns value.","code":""},{"path":"http://processx.r-lib.org/dev/reference/process.html","id":"usage-34","dir":"Reference","previous_headings":"","what":"Usage","title":"External process — process","text":"","code":"process$get_output_file()"},{"path":"http://processx.r-lib.org/dev/reference/process.html","id":"method-get-error-file-","dir":"Reference","previous_headings":"","what":"Method get_error_file()","title":"External process — process","text":"$get_error_file() stderr argument filename, returns absolute path file. stderr \"|\" NULL, simply returns value.","code":""},{"path":"http://processx.r-lib.org/dev/reference/process.html","id":"usage-35","dir":"Reference","previous_headings":"","what":"Usage","title":"External process — process","text":"","code":"process$get_error_file()"},{"path":"http://processx.r-lib.org/dev/reference/process.html","id":"method-poll-io-","dir":"Reference","previous_headings":"","what":"Method poll_io()","title":"External process — process","text":"$poll_io() polls process's connections /O. See Polling section, see also poll() function poll multiple processes.","code":""},{"path":"http://processx.r-lib.org/dev/reference/process.html","id":"usage-36","dir":"Reference","previous_headings":"","what":"Usage","title":"External process — process","text":"","code":"process$poll_io(timeout)"},{"path":"http://processx.r-lib.org/dev/reference/process.html","id":"arguments-11","dir":"Reference","previous_headings":"","what":"Arguments","title":"External process — process","text":"timeout Timeout milliseconds, wait /O polling.","code":""},{"path":"http://processx.r-lib.org/dev/reference/process.html","id":"method-get-poll-connection-","dir":"Reference","previous_headings":"","what":"Method get_poll_connection()","title":"External process — process","text":"$get_poll_connetion() returns poll connection, process one.","code":""},{"path":"http://processx.r-lib.org/dev/reference/process.html","id":"usage-37","dir":"Reference","previous_headings":"","what":"Usage","title":"External process — process","text":"","code":"process$get_poll_connection()"},{"path":"http://processx.r-lib.org/dev/reference/process.html","id":"method-get-result-","dir":"Reference","previous_headings":"","what":"Method get_result()","title":"External process — process","text":"$get_result() returns result post processesing function. can called process finished. process post-processing function, NULL returned.","code":""},{"path":"http://processx.r-lib.org/dev/reference/process.html","id":"usage-38","dir":"Reference","previous_headings":"","what":"Usage","title":"External process — process","text":"","code":"process$get_result()"},{"path":"http://processx.r-lib.org/dev/reference/process.html","id":"method-as-ps-handle-","dir":"Reference","previous_headings":"","what":"Method as_ps_handle()","title":"External process — process","text":"$as_ps_handle() returns ps::ps_handle object, corresponding process.","code":""},{"path":"http://processx.r-lib.org/dev/reference/process.html","id":"usage-39","dir":"Reference","previous_headings":"","what":"Usage","title":"External process — process","text":"","code":"process$as_ps_handle()"},{"path":"http://processx.r-lib.org/dev/reference/process.html","id":"method-get-name-","dir":"Reference","previous_headings":"","what":"Method get_name()","title":"External process — process","text":"Calls ps::ps_name() get process name.","code":""},{"path":"http://processx.r-lib.org/dev/reference/process.html","id":"usage-40","dir":"Reference","previous_headings":"","what":"Usage","title":"External process — process","text":"","code":"process$get_name()"},{"path":"http://processx.r-lib.org/dev/reference/process.html","id":"method-get-exe-","dir":"Reference","previous_headings":"","what":"Method get_exe()","title":"External process — process","text":"Calls ps::ps_exe() get path executable.","code":""},{"path":"http://processx.r-lib.org/dev/reference/process.html","id":"usage-41","dir":"Reference","previous_headings":"","what":"Usage","title":"External process — process","text":"","code":"process$get_exe()"},{"path":"http://processx.r-lib.org/dev/reference/process.html","id":"method-get-cmdline-","dir":"Reference","previous_headings":"","what":"Method get_cmdline()","title":"External process — process","text":"Calls ps::ps_cmdline() get command line.","code":""},{"path":"http://processx.r-lib.org/dev/reference/process.html","id":"usage-42","dir":"Reference","previous_headings":"","what":"Usage","title":"External process — process","text":"","code":"process$get_cmdline()"},{"path":"http://processx.r-lib.org/dev/reference/process.html","id":"method-get-status-","dir":"Reference","previous_headings":"","what":"Method get_status()","title":"External process — process","text":"Calls ps::ps_status() get process status.","code":""},{"path":"http://processx.r-lib.org/dev/reference/process.html","id":"usage-43","dir":"Reference","previous_headings":"","what":"Usage","title":"External process — process","text":"","code":"process$get_status()"},{"path":"http://processx.r-lib.org/dev/reference/process.html","id":"method-get-username-","dir":"Reference","previous_headings":"","what":"Method get_username()","title":"External process — process","text":"calls ps::ps_username() get username.","code":""},{"path":"http://processx.r-lib.org/dev/reference/process.html","id":"usage-44","dir":"Reference","previous_headings":"","what":"Usage","title":"External process — process","text":"","code":"process$get_username()"},{"path":"http://processx.r-lib.org/dev/reference/process.html","id":"method-get-wd-","dir":"Reference","previous_headings":"","what":"Method get_wd()","title":"External process — process","text":"Calls ps::ps_cwd() get current working directory.","code":""},{"path":"http://processx.r-lib.org/dev/reference/process.html","id":"usage-45","dir":"Reference","previous_headings":"","what":"Usage","title":"External process — process","text":"","code":"process$get_wd()"},{"path":"http://processx.r-lib.org/dev/reference/process.html","id":"method-get-cpu-times-","dir":"Reference","previous_headings":"","what":"Method get_cpu_times()","title":"External process — process","text":"Calls ps::ps_cpu_times() get CPU usage data.","code":""},{"path":"http://processx.r-lib.org/dev/reference/process.html","id":"usage-46","dir":"Reference","previous_headings":"","what":"Usage","title":"External process — process","text":"","code":"process$get_cpu_times()"},{"path":"http://processx.r-lib.org/dev/reference/process.html","id":"method-get-memory-info-","dir":"Reference","previous_headings":"","what":"Method get_memory_info()","title":"External process — process","text":"Calls ps::ps_memory_info() get memory data.","code":""},{"path":"http://processx.r-lib.org/dev/reference/process.html","id":"usage-47","dir":"Reference","previous_headings":"","what":"Usage","title":"External process — process","text":"","code":"process$get_memory_info()"},{"path":"http://processx.r-lib.org/dev/reference/process.html","id":"method-suspend-","dir":"Reference","previous_headings":"","what":"Method suspend()","title":"External process — process","text":"Calls ps::ps_suspend() suspend process.","code":""},{"path":"http://processx.r-lib.org/dev/reference/process.html","id":"usage-48","dir":"Reference","previous_headings":"","what":"Usage","title":"External process — process","text":"","code":"process$suspend()"},{"path":"http://processx.r-lib.org/dev/reference/process.html","id":"method-resume-","dir":"Reference","previous_headings":"","what":"Method resume()","title":"External process — process","text":"Calls ps::ps_resume() resume suspended process.","code":""},{"path":"http://processx.r-lib.org/dev/reference/process.html","id":"usage-49","dir":"Reference","previous_headings":"","what":"Usage","title":"External process — process","text":"","code":"process$resume()"},{"path":"http://processx.r-lib.org/dev/reference/process.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"External process — process","text":"","code":"p <- process$new(\"sleep\", \"2\") p$is_alive() #> [1] TRUE p #> PROCESS 'sleep', running, pid 6302. p$kill() #> [1] TRUE p$is_alive() #> [1] FALSE p <- process$new(\"sleep\", \"1\") p$is_alive() #> [1] TRUE Sys.sleep(2) p$is_alive() #> [1] FALSE"},{"path":"http://processx.r-lib.org/dev/reference/process_initialize.html","id":null,"dir":"Reference","previous_headings":"","what":"Start a process — process_initialize","title":"Start a process — process_initialize","text":"Start process","code":""},{"path":"http://processx.r-lib.org/dev/reference/process_initialize.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Start a process — process_initialize","text":"","code":"process_initialize( self, private, command, args, stdin, stdout, stderr, pty, pty_options, connections, poll_connection, env, cleanup, cleanup_tree, wd, echo_cmd, supervise, windows_verbatim_args, windows_hide_window, windows_detached_process, encoding, post_process )"},{"path":"http://processx.r-lib.org/dev/reference/process_initialize.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Start a process — process_initialize","text":"self private $private command Command run, string scalar. args Command arguments, character vector. stdin Standard input, NULL ignore. stdout Standard output, NULL ignore, TRUE temp file. stderr Standard error, NULL ignore, TRUE temp file. pty Whether create PTY. connections Connections inherit child process. poll_connection Whether create connection polling. env Environment vaiables. cleanup Kill GC? cleanup_tree Kill process tree GC? wd working directory (NULL) echo_cmd Echo command starting ? supervise process supervised? encoding Assumed stdout stderr encoding. post_process Post processing function.","code":""},{"path":"http://processx.r-lib.org/dev/reference/processx-package.html","id":null,"dir":"Reference","previous_headings":"","what":"processx: Execute and Control System Processes — processx-package","title":"processx: Execute and Control System Processes — processx-package","text":"Tools run system processes background. can check background process running; wait background process finish; get exit status finished processes; kill background processes. can read standard output error processes, using non-blocking connections. 'processx' can poll process standard output error, timeout. can also poll several processes .","code":""},{"path":[]},{"path":"http://processx.r-lib.org/dev/reference/processx-package.html","id":"author","dir":"Reference","previous_headings":"","what":"Author","title":"processx: Execute and Control System Processes — processx-package","text":"Maintainer: Gábor Csárdi csardi.gabor@gmail.com (ORCID) [copyright holder] Authors: Winston Chang contributors: Posit Software, PBC [copyright holder, funder] Ascent Digital Services [copyright holder, funder]","code":""},{"path":"http://processx.r-lib.org/dev/reference/processx_connections.html","id":null,"dir":"Reference","previous_headings":"","what":"Processx connections — conn_create_fd","title":"Processx connections — conn_create_fd","text":"functions currently experimental change future. Note processx connections compatible R's built-connection system.","code":""},{"path":"http://processx.r-lib.org/dev/reference/processx_connections.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Processx connections — conn_create_fd","text":"","code":"conn_create_fd(fd, encoding = \"\", close = TRUE) conn_file_name(con) conn_create_pipepair(encoding = \"\", nonblocking = c(TRUE, FALSE)) conn_read_chars(con, n = -1) # S3 method for class 'processx_connection' conn_read_chars(con, n = -1) processx_conn_read_chars(con, n = -1) conn_read_lines(con, n = -1) # S3 method for class 'processx_connection' conn_read_lines(con, n = -1) processx_conn_read_lines(con, n = -1) conn_is_incomplete(con) # S3 method for class 'processx_connection' conn_is_incomplete(con) processx_conn_is_incomplete(con) conn_write(con, str, sep = \"\\n\", encoding = \"\") # S3 method for class 'processx_connection' conn_write(con, str, sep = \"\\n\", encoding = \"\") processx_conn_write(con, str, sep = \"\\n\", encoding = \"\") conn_create_file(filename, read = NULL, write = NULL) conn_set_stdout(con, drop = TRUE) conn_set_stderr(con, drop = TRUE) conn_get_fileno(con) conn_disable_inheritance() # S3 method for class 'processx_connection' close(con, ...) processx_conn_close(con, ...) is_valid_fd(fd)"},{"path":"http://processx.r-lib.org/dev/reference/processx_connections.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Processx connections — conn_create_fd","text":"fd Integer scalar, Unix file descriptor. encoding Encoding readable connection reading. close Whether close OS file descriptor closing connection. Sometimes want leave open, use conn_create_fd call. Encoding re-encode str writing. con Processx connection object. nonblocking Whether pipe non-blocking. conn_create_pipepair() must logical vector length two, ends pipe. n Number characters lines read. -1 means available characters lines. str Character raw vector write. sep Separator use str character vector. Ignored str raw vector. filename File name. conn_create_pipe() Windows, \\\\?\\pipe prefix added , prefix. conn_create_pipe() can also NULL, case random file name used via tempfile(). read Whether connection readable. write Whethe connection writeable. drop Whether close original stdout/stderr, keep open return connection . ... Extra arguments, compatibility close() generic, currently ignored processx.","code":""},{"path":"http://processx.r-lib.org/dev/reference/processx_connections.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Processx connections — conn_create_fd","text":"conn_create_fd() creates connection file descriptor. conn_file_name() returns name file associated connection. connections refer file file system returns NA_character(). Except named pipes Windows, returns full name pipe. conn_create_pipepair() creates pair connected connections, first one writeable, second one readable. conn_read_chars() reads UTF-8 characters connections. connection UTF-8 encoded, re-encodes . conn_read_lines() reads lines connection. conn_is_incomplete() returns FALSE connection surely data. conn_write() writes character raw vector connection. might able write bytes connection, case returns leftover bytes raw vector. Call conn_write() raw vector. conn_create_file() creates connection file. conn_set_stdout() set standard output R process, specified connection. conn_set_stderr() set standard error R process, specified connection. conn_get_fileno() return integer file desciptor belongs connection. conn_disable_inheritance() can called disable inheritance open handles. Call function soon possible new process avoid inheriting inherited handles even . function best effort close handles, might still leave handles open. work stdin, stdout stderr, least. is_valid_fd() returns TRUE fd valid open file descriptor. can use check R process standard input, output error. E.g. R processes running GUI (like RGui) might standard streams available. stream redirected null device (e.g. callr subprocess), still valid file descriptor.","code":""},{"path":"http://processx.r-lib.org/dev/reference/processx_connections.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Processx connections — conn_create_fd","text":"","code":"is_valid_fd(0L) # stdin #> [1] TRUE is_valid_fd(1L) # stdout #> [1] TRUE is_valid_fd(2L) # stderr #> [1] TRUE"},{"path":"http://processx.r-lib.org/dev/reference/processx_fifos.html","id":null,"dir":"Reference","previous_headings":"","what":"Processx FIFOs — conn_create_fifo","title":"Processx FIFOs — conn_create_fifo","text":"Create FIFO inter-process communication Note functions currently experimental.","code":""},{"path":"http://processx.r-lib.org/dev/reference/processx_fifos.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Processx FIFOs — conn_create_fifo","text":"","code":"conn_create_fifo( filename = NULL, read = NULL, write = NULL, encoding = \"\", nonblocking = TRUE ) conn_connect_fifo( filename, read = NULL, write = NULL, encoding = \"\", nonblocking = TRUE )"},{"path":"http://processx.r-lib.org/dev/reference/processx_fifos.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Processx FIFOs — conn_create_fifo","text":"filename File name FIFO. Windows name pipe within \\\\?\\pipe\\ namespace, either full name, part prefix. NULL, random name used, Unix R temporary directory: base::tempdir(). read TRUE connect read end FIFO. Exactly one read write must set TRUE. write TRUE connect write end FIFO. Exactly one read write must set TRUE. encoding Encoding assume. nonblocking Whether non-blocking FIFO. Note blocking FIFOs well tested might work well poll(), especially Windows. might remove option future make FIFOs non-blocking.","code":""},{"path":"http://processx.r-lib.org/dev/reference/processx_fifos.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Processx FIFOs — conn_create_fifo","text":"conn_create_fifo() creates FIFO connects . Unix proper FIFO file system, R temporary directory. Windows named pipe. Use conn_file_name() query name FIFO, conn_connect_fifo() connect end. conn_connect_fifo() connects FIFO created conn_create_fifo(), typically another process. filename refers name pipe Windows. Windows, conn_connect_fifo() may successful even FIFO exist, later poll() read/write operations fail. planning changing behavior future, make conn_connect_fifo() fail immediately, like Unix.","code":""},{"path":[]},{"path":"http://processx.r-lib.org/dev/reference/processx_fifos.html","id":"in-general-unix-domain-sockets-work-better-than-fifos-so-we-suggest","dir":"Reference","previous_headings":"","what":"In general Unix domain sockets work better than FIFOs, so we suggest","title":"Processx FIFOs — conn_create_fifo","text":"use sockets can. See conn_create_unix_socket().","code":""},{"path":"http://processx.r-lib.org/dev/reference/processx_fifos.html","id":"creating-the-read-end-of-the-fifo","dir":"Reference","previous_headings":"","what":"Creating the read end of the FIFO","title":"Processx FIFOs — conn_create_fifo","text":"case simpler. wait writer connect FIFO can use poll() usual. use conn_read_chars() conn_read_lines() read FIFO, usual. Use conn_is_incomplete() read check data, writer done.","code":""},{"path":"http://processx.r-lib.org/dev/reference/processx_fifos.html","id":"creating-the-write-end-of-the-fifo","dir":"Reference","previous_headings":"","what":"Creating the write end of the FIFO","title":"Processx FIFOs — conn_create_fifo","text":"somewhat trickier. Creating (non-blocking) FIFO block. However, easy way tell reader connected end FIFO . Unix can start using conn_write() try write , succeed, buffer gets full, even reader. (buffer full return data written, usual.) Windows, using conn_write() write FIFO without reader fails error. great, planning improve later. Right now, one workaround behavior reader connunicate writer process independenctly connected FIFO. (E.g. another FIFO opposite direction can .)","code":""},{"path":[]},{"path":"http://processx.r-lib.org/dev/reference/processx_fifos.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Processx FIFOs — conn_create_fifo","text":"","code":"# Example for a non-blocking FIFO # Need to open the reading end first, otherwise Unix fails reader <- conn_create_fifo() # Always use poll() before you read, with a timeout if you like. # If you read before the other end of the FIFO is connected, then # the OS (or processx?) assumes that the FIFO is done, and you cannot # read anything. # Now poll() tells us that there is no data yet. poll(list(reader), 0) #> [[1]] #> [1] \"timeout\" #> writer <- conn_connect_fifo(conn_file_name(reader), write = TRUE) conn_write(writer, \"hello\\nthere!\\n\") poll(list(reader), 1000) #> [[1]] #> [1] \"ready\" #> conn_read_lines(reader, 1) #> [1] \"hello\" conn_read_chars(reader) #> [1] \"there!\\n\" conn_is_incomplete(reader) #> [1] TRUE close(writer) #> NULL conn_read_chars(reader) #> [1] \"\" conn_is_incomplete(reader) #> [1] FALSE close(reader) #> NULL"},{"path":"http://processx.r-lib.org/dev/reference/processx_sockets.html","id":null,"dir":"Reference","previous_headings":"","what":"Unix domain sockets — conn_create_unix_socket","title":"Unix domain sockets — conn_create_unix_socket","text":"Cross platform point--point inter-process communication Unix=domain sockets, implemented via named pipes Windows. connection always bidirectional, .e. can read also write .","code":""},{"path":"http://processx.r-lib.org/dev/reference/processx_sockets.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Unix domain sockets — conn_create_unix_socket","text":"","code":"conn_create_unix_socket(filename = NULL, encoding = \"\") conn_connect_unix_socket(filename, encoding = \"\") conn_accept_unix_socket(con) conn_unix_socket_state(con)"},{"path":"http://processx.r-lib.org/dev/reference/processx_sockets.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Unix domain sockets — conn_create_unix_socket","text":"filename File name socket. Windows name pipe within \\\\?\\pipe\\ namespace, either full name, part prefix. NULL, random name used, Unix R temporary directory: base::tempdir(). encoding Encoding assume reading socket. con Connection. error thrown socket connection.","code":""},{"path":"http://processx.r-lib.org/dev/reference/processx_sockets.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Unix domain sockets — conn_create_unix_socket","text":"new socket connection.","code":""},{"path":"http://processx.r-lib.org/dev/reference/processx_sockets.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Unix domain sockets — conn_create_unix_socket","text":"conn_create_unix_socket() creates server socket. new socket listening filename. See filename . conn_connect_unix_socket() creates client socket connects server socket. conn_accept_unix_socket() accepts client connection server socket. conn_unix_socket_state() returns state socket. Currently can return: \"listening\", \"connected_server\", \"connected_client\". possible states (e.g. closed socket) added future.","code":""},{"path":"http://processx.r-lib.org/dev/reference/processx_sockets.html","id":"notes","dir":"Reference","previous_headings":"","what":"Notes","title":"Unix domain sockets — conn_create_unix_socket","text":"poll() works sockets, polls data read, currently ignores write-end socket. poll() also works accepting client connections. return \"connect\"client connection available server socket. can call conn_accept_unix_socket() accept client connection.","code":""},{"path":[]},{"path":"http://processx.r-lib.org/dev/reference/run.html","id":null,"dir":"Reference","previous_headings":"","what":"Run external command, and wait until finishes — run","title":"Run external command, and wait until finishes — run","text":"run provides interface similar base::system() base::system2(), based process class. allows extra features, see .","code":""},{"path":"http://processx.r-lib.org/dev/reference/run.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Run external command, and wait until finishes — run","text":"","code":"run( command = NULL, args = character(), error_on_status = TRUE, wd = NULL, echo_cmd = FALSE, echo = FALSE, spinner = FALSE, timeout = Inf, stdout = \"|\", stderr = \"|\", stdout_line_callback = NULL, stdout_callback = NULL, stderr_line_callback = NULL, stderr_callback = NULL, stderr_to_stdout = FALSE, env = NULL, windows_verbatim_args = FALSE, windows_hide_window = FALSE, encoding = \"\", cleanup_tree = FALSE, ... )"},{"path":"http://processx.r-lib.org/dev/reference/run.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Run external command, and wait until finishes — run","text":"command Character scalar, command run. running .bat .cmd files Windows, make sure read 'Batch files' section process manual page. args Character vector, arguments command. error_on_status Whether throw error command returns non-zero status, interrupted. error classes system_command_status_error system_command_timeout_error, respectively, errors class system_command_error well. See also \"Error conditions\" . wd Working directory process. NULL, current working directory used. echo_cmd Whether print command run screen. echo Whether print standard output error screen. Note order standard output error lines necessarily correct, standard output typically buffered. standard output /error redirected file ignored, also echoed. spinner Whether show reassuring spinner process running. timeout Timeout process, seconds, difftime object. finished , killed. stdout standard output. default collected result, can also use stdout_line_callback stdout_callback arguments pass callbacks output. empty string (\"\"), child process inherits standard output stream R process. (main R process standard output stream, e.g. RGui Windows, error thrown.) NULL, standard output discarded. string \"|\" \"\", taken file name output redirected file. stderr standard error. default collected result, can also use stderr_line_callback stderr_callback arguments pass callbacks output. empty string (\"\"), child process inherits standard error stream R process. (main R process standard error stream, e.g. RGui Windows, error thrown.) NULL, standard error discarded. string \"|\" \"\", taken file name standard error redirected file. stdout_line_callback NULL, function call every line standard output. See stdout_callback also . stdout_callback NULL, function call every chunk standard output. chunk can small single character. one stdout_line_callback stdout_callback can non-NULL. stderr_line_callback NULL, function call every line standard error. See stderr_callback also . stderr_callback NULL, function call every chunk standard error. chunk can small single character. one stderr_line_callback stderr_callback can non-NULL. stderr_to_stdout Whether redirect standard error standard output. Specifying TRUE keep standard output, correctly interleaved. However, possible deduce pieces output coming . TRUE, standard error callbacks () never called. env Environment variables child process. NULL, parent's environment inherited. Windows, many programs function correctly environment variables set, always set HOMEDRIVE, HOMEPATH, LOGONSERVER, PATH, SYSTEMDRIVE, SYSTEMROOT, TEMP, USERDOMAIN, USERNAME, USERPROFILE WINDIR. append new environment variables ones set current process, specify \"current\" env, without name, appended ones names. appended ones can overwrite current ones. windows_verbatim_args Whether omit escaping command arguments windows. Ignored platforms. windows_hide_window Whether hide window application windows. Ignored platforms. encoding encoding assume stdout stderr. default encoding current locale used. Note processx always reencodes output streams UTF-8 currently. cleanup_tree Whether clean child process tree process finished. ... Extra arguments passed process$new(), see process. Note pass stout stderr , used internally run(). can use stdout_callback, stderr_callback, etc. arguments manage standard output error, process class directly need flexibility.","code":""},{"path":"http://processx.r-lib.org/dev/reference/run.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Run external command, and wait until finishes — run","text":"list components: status exit status process. NA, process killed exit status. stdout standard output command, character scalar. stderr standard error command, character scalar. timeout Whether process killed timeout.","code":""},{"path":"http://processx.r-lib.org/dev/reference/run.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Run external command, and wait until finishes — run","text":"run supports Specifying timeout command. specified time passed, process still running, killed (child processes). Calling callback function line chunk standard output /error. chunk may contain multiple lines, can short single character. Cleaning subprocess, whole process tree, exiting.","code":""},{"path":"http://processx.r-lib.org/dev/reference/run.html","id":"callbacks","dir":"Reference","previous_headings":"","what":"Callbacks","title":"Run external command, and wait until finishes — run","text":"notes callback functions. first argument callback function character scalar (length 1 character), single output error line. second argument always process object. can manipulate object, example can call $kill() terminate , response message standard output error.","code":""},{"path":"http://processx.r-lib.org/dev/reference/run.html","id":"error-conditions","dir":"Reference","previous_headings":"","what":"Error conditions","title":"Run external command, and wait until finishes — run","text":"run() throws error condition objects process interrupted, timeouts fails (error_on_status TRUE): interrupt, condition classes system_command_interrupt, interrupt, condition signalled. can caught tryCatch(..., interrupt = ...). timeout, condition classes system_command_timeout_error, system_command_error, error, condition thrown. error (error_on_status TRUE), error classes system_command_status_error, system_command_error, error, condition thrown. conditions fields: message: error message, stderr: standard error process, standard output process stderr_to_stdout TRUE. call: captured call run(). echo: value echo argument. stderr_to_stdout: value stderr_to_stdout argument. status: exit status system_command_status_error errors.","code":""},{"path":"http://processx.r-lib.org/dev/reference/run.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Run external command, and wait until finishes — run","text":"","code":"# This works on Unix systems run(\"ls\") #> $status #> [1] 0 #> #> $stdout #> [1] \"base64_decode.html\\ncurl_fds.html\\ndefault_pty_options.html\\nfigures\\nindex.html\\npoll.html\\nprocess.html\\nprocess_initialize.html\\nprocessx-package.html\\nprocessx_connections.html\\nprocessx_fifos.html\\nprocessx_sockets.html\\n\" #> #> $stderr #> [1] \"\" #> #> $timeout #> [1] FALSE #> system.time(run(\"sleep\", \"10\", timeout = 1, error_on_status = FALSE)) #> user system elapsed #> 0.004 0.019 0.258 system.time( run( \"sh\", c(\"-c\", \"for i in 1 2 3 4 5; do echo $i; sleep 1; done\"), timeout = 2, error_on_status = FALSE ) ) #> user system elapsed #> 0.005 0.010 1.254 if (FALSE) { # This works on Windows systems, if the ping command is available run(\"ping\", c(\"-n\", \"1\", \"127.0.0.1\")) run(\"ping\", c(\"-n\", \"6\", \"127.0.0.1\"), timeout = 1, error_on_status = FALSE) }"},{"path":"http://processx.r-lib.org/dev/reference/supervisor_kill.html","id":null,"dir":"Reference","previous_headings":"","what":"Terminate all supervised processes and the supervisor process itself as well — supervisor_kill","title":"Terminate all supervised processes and the supervisor process itself as well — supervisor_kill","text":"Unix supervisor sends SIGTERM signal supervised processes, gives five seconds quit, sending SIGKILL signal. supervisor terminates.","code":""},{"path":"http://processx.r-lib.org/dev/reference/supervisor_kill.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Terminate all supervised processes and the supervisor process itself as well — supervisor_kill","text":"","code":"supervisor_kill()"},{"path":"http://processx.r-lib.org/dev/reference/supervisor_kill.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Terminate all supervised processes and the supervisor process itself as well — supervisor_kill","text":"Windows similar, instead SIGTERM, console CTRL+C interrupt sent first, WM_CLOSE message sent windows supervised processes, windows.","code":""},{"path":"http://processx.r-lib.org/dev/news/index.html","id":"processx-development-version","dir":"Changelog","previous_headings":"","what":"processx (development version)","title":"processx (development version)","text":"changes.","code":""},{"path":"http://processx.r-lib.org/dev/news/index.html","id":"processx-384","dir":"Changelog","previous_headings":"","what":"processx 3.8.4","title":"processx 3.8.4","text":"CRAN release: 2024-03-16 changes.","code":""},{"path":"http://processx.r-lib.org/dev/news/index.html","id":"processx-383","dir":"Changelog","previous_headings":"","what":"processx 3.8.3","title":"processx 3.8.3","text":"CRAN release: 2023-12-10 *printf() format strings now safer (#379).","code":""},{"path":"http://processx.r-lib.org/dev/news/index.html","id":"processx-382","dir":"Changelog","previous_headings":"","what":"processx 3.8.2","title":"processx 3.8.2","text":"CRAN release: 2023-06-30 client library, used callr, now ignores SIGPIPE writing file descriptor, unix. avoid possible freezes callr::r_session subprocess trying report result main process terminated. particular, happened parallel testthat: https://github.com/r-lib/testthat/issues/1819","code":""},{"path":"http://processx.r-lib.org/dev/news/index.html","id":"processx-381","dir":"Changelog","previous_headings":"","what":"processx 3.8.1","title":"processx 3.8.1","text":"CRAN release: 2023-04-18 Unixes, R processes created callr now feature SIGTERM cleanup handler cleans temporary directory shutting . enable , set PROCESSX_R_SIGTERM_CLEANUP envvar non-empty value.","code":""},{"path":"http://processx.r-lib.org/dev/news/index.html","id":"processx-380","dir":"Changelog","previous_headings":"","what":"processx 3.8.0","title":"processx 3.8.0","text":"CRAN release: 2022-10-26 processx error stacks better now. ANSI hyperlinks function calls manual pages, also print operators better. processx now mark standard streams close--exec Unix, causes problems calling system() R subprocess (https://github.com/r-lib/callr/issues/236).","code":""},{"path":"http://processx.r-lib.org/dev/news/index.html","id":"processx-370","dir":"Changelog","previous_headings":"","what":"processx 3.7.0","title":"processx 3.7.0","text":"CRAN release: 2022-07-07 New functions creating portable FIFOs Unix socket connections. See conn_create_fifo(), conn_create_unix_socket() vignettes/internals.Rmd documentation. functions currently experimental.","code":""},{"path":"http://processx.r-lib.org/dev/news/index.html","id":"processx-361","dir":"Changelog","previous_headings":"","what":"processx 3.6.1","title":"processx 3.6.1","text":"CRAN release: 2022-06-17 processx now closes file unneeded file descriptors redirecting standard output error, client file. processx errors now rlang_error rlang_trace classes, actually compatible rlang errors traces.","code":""},{"path":"http://processx.r-lib.org/dev/news/index.html","id":"processx-360","dir":"Changelog","previous_headings":"","what":"processx 3.6.0","title":"processx 3.6.0","text":"CRAN release: 2022-06-10 processx now gives better error messages, better stack traces.","code":""},{"path":"http://processx.r-lib.org/dev/news/index.html","id":"processx-353","dir":"Changelog","previous_headings":"","what":"processx 3.5.3","title":"processx 3.5.3","text":"CRAN release: 2022-03-25 run() now sets stderr NULL result (instead empty string), standard error redirected standard output. also fixes error interrupting run() redirected standard error. processx now fail current working directory contains non-ASCII character Windows, getwd() returns short path (#313).","code":""},{"path":"http://processx.r-lib.org/dev/news/index.html","id":"processx-352","dir":"Changelog","previous_headings":"","what":"processx 3.5.2","title":"processx 3.5.2","text":"CRAN release: 2021-04-30 run() now truncate stdout stderr output contains multibyte characters (#298, @infotroph). processx now compiles custom compilers enable OpenMP (#297). processx now avoids race condition working directory changed right starting process, potentially sub-process initialized (#300). processx now works non-ASCII path names non-UTF-8 Unix platforms (#293).","code":""},{"path":"http://processx.r-lib.org/dev/news/index.html","id":"processx-351","dir":"Changelog","previous_headings":"","what":"processx 3.5.1","title":"processx 3.5.1","text":"CRAN release: 2021-04-04 Fix potential failure polling curl file descriptors Windows.","code":""},{"path":"http://processx.r-lib.org/dev/news/index.html","id":"processx-350","dir":"Changelog","previous_headings":"","what":"processx 3.5.0","title":"processx 3.5.0","text":"CRAN release: 2021-03-23 can now append environment variables ones set current process include \"current\" value env, run() process$new(): env = c(\"current\", NEW = \"newvalue\") (#232). Sub-processes can now inherit standard input, output error main R process, setting corresponding argument empty string. E.g. run(\"ls\", stdout = \"\") (#72). run() now much faster large standard output standard error (#286). run() can now discard standard output error redirect file(s), instead collecting . processx now optionally uses cli package color error messages stack traces, instead crayon.","code":""},{"path":"http://processx.r-lib.org/dev/news/index.html","id":"processx-345","dir":"Changelog","previous_headings":"","what":"processx 3.4.5","title":"processx 3.4.5","text":"CRAN release: 2020-11-30 New options pty_options set initial size pseudo terminal. Reading standard output error now crash occasionally \\n character beginning input buffer (#281).","code":""},{"path":"http://processx.r-lib.org/dev/news/index.html","id":"processx-344","dir":"Changelog","previous_headings":"","what":"processx 3.4.4","title":"processx 3.4.4","text":"CRAN release: 2020-09-03 processx now works correctly non-ASCII commands arguments passed native encoding, Windows (#261, #262, #263, #264). Providing multiple environment variables now works windows (#267).","code":""},{"path":"http://processx.r-lib.org/dev/news/index.html","id":"processx-343","dir":"Changelog","previous_headings":"","what":"processx 3.4.3","title":"processx 3.4.3","text":"CRAN release: 2020-07-05 supervisor (activated supervise = TRUE) crash Windows Subsystem Linux (WSL) now (#222). Fix ABI compatibility pre post R 4.0.1 versions. Now CRAN builds (R 4.0.2 later 4.0.x) work well R 4.0.0. Now processx can run commands UNC paths specified forward slashes: //hostname/... UNC paths usual back-slashes always fine (#249). $as_ps_handle() method works now better; previously sometimes created invalid ps::ps_handle object, system clock changed (#258).","code":""},{"path":"http://processx.r-lib.org/dev/news/index.html","id":"processx-342","dir":"Changelog","previous_headings":"","what":"processx 3.4.2","title":"processx 3.4.2","text":"CRAN release: 2020-02-09 run() now better job displaying spinner terminals buffer output (#223). Error messages now fully printed error. non-interactive sessions, stack trace printed well. improved error messages. Errors C code now include name C function, errors belong process include system command (#197). processx crash now process receives SIGPIPE signal trying write pipe, end already exited. processx now works better fork clusters parallel package. See ‘Mixing processx parallel base R package’ README file (#236). processx now block SIGCHLD default subprocess, blocking potentially causes zombie sub-subprocesses (#240). process$wait() method now leak file descriptors Unix interrupted (#141).","code":""},{"path":"http://processx.r-lib.org/dev/news/index.html","id":"processx-341","dir":"Changelog","previous_headings":"","what":"processx 3.4.1","title":"processx 3.4.1","text":"CRAN release: 2019-07-18 Now run() create ok variable global environment.","code":""},{"path":"http://processx.r-lib.org/dev/news/index.html","id":"processx-340","dir":"Changelog","previous_headings":"","what":"processx 3.4.0","title":"processx 3.4.0","text":"CRAN release: 2019-07-03 Processx now better error messages, particular, errors C code contain file name line number, system error code message (applicable). Processx now sets .Last.error variable every un-caught processx error error condition, also sets .Last.error.trace stack trace. run() now prints last 10 lines standard error stream error, echo = FALSE, also prints exit status process. run() now includes standard error condition signalled interrupt. process now supports creating pseudo terminals Unix systems. conn_create_pipepair() gets new argument set pipes blocking non-blocking. process set inherited extra connections blocking, also close starting subprocess. now responsibility user. Note breaking change. run() now passes extra ... arguments process$new(). run() now error process killed callback.","code":""},{"path":"http://processx.r-lib.org/dev/news/index.html","id":"processx-331","dir":"Changelog","previous_headings":"","what":"processx 3.3.1","title":"processx 3.3.1","text":"CRAN release: 2019-05-08 Fix crash Windows, connection pending read internally finalized.","code":""},{"path":"http://processx.r-lib.org/dev/news/index.html","id":"processx-330","dir":"Changelog","previous_headings":"","what":"processx 3.3.0","title":"processx 3.3.0","text":"CRAN release: 2019-03-10 process can now redirect standard error standard output, via specifying stderr = \"2>&1\". works files pipes. run() can now redirect standard error standard output, via new stderr_to_stdout argument. $kill() $kill_tree() methods get close_connection = TRUE argument closes pipe connections process. run() now always kills process (process tree cleanup_tree TRUE) exiting. also closes pipe connections (#149).","code":""},{"path":"http://processx.r-lib.org/dev/news/index.html","id":"processx-321","dir":"Changelog","previous_headings":"","what":"processx 3.2.1","title":"processx 3.2.1","text":"CRAN release: 2018-12-05 processx depend assertthat now, crayon package now optional dependency.","code":""},{"path":"http://processx.r-lib.org/dev/news/index.html","id":"processx-320","dir":"Changelog","previous_headings":"","what":"processx 3.2.0","title":"processx 3.2.0","text":"CRAN release: 2018-08-16 New process$kill_tree() method, new cleanup_tree arguments run() process$new(), clean process tree rooted processx process. (#139, #143). New process$interupt() method send interrupt process, SIGINT Unix, CTRL+C Windows (#127). New stdin argument process$new() support writing standard input process (#27, #114). New connections argument process$new() support passing extra connections child process, addition standard streams. New poll_connection argument process$new(), extra connection can used poll process, even stdout stderr pipes (#125). poll() now works connections objects, can mixed process objects (#121). New env argument run() process$new(), set environment child process, optionally (#117, #118). Removed $restart() method, less useful expected, hard maintain (#116). New conn_set_stdout() conn_set_stderr() set standard output error calling process. New conn_disable_inheritance() disable stdio inheritance. suggested child processes call immediately starting, file handles inherited . Fixed signal handler bug Unix marked process finished, even (d221aa1f). Fixed bug occasionally caused crashes wait(), Unix (#138). run() interrupted, error message printed, just like interruption R code general. thrown condition now also interrupt class (#148).","code":""},{"path":"http://processx.r-lib.org/dev/news/index.html","id":"processx-310","dir":"Changelog","previous_headings":"","what":"processx 3.1.0","title":"processx 3.1.0","text":"CRAN release: 2018-05-15 Fix interference parallel package, packages redefine SIGCHLD signal handler Unix. processx signal handler overwritten, might miss exit status processes (set NA). run() process$new() allow specifying working directory process (#63). Make debugme package optional dependency (#74). processx now compatible R 3.1.x. Allow polling 64 connections Windows, using IOCP instead WaitForMultipleObjects() (#81, #106). Fix race condition Windows, creating named pipes stdout stderr. client sometimes didn’t wait server, processx failed ERROR_PIPE_BUSY (231, pipe instances busy).","code":""},{"path":"http://processx.r-lib.org/dev/news/index.html","id":"processx-303","dir":"Changelog","previous_headings":"","what":"processx 3.0.3","title":"processx 3.0.3","text":"CRAN release: 2018-05-07 Fix crash windows trying run non-existing command (#90) Fix race condition process$restart() run() process$new() support commandline argument , process cleanup error prone intermediate shell. (#88) processx process objects longer use R connection objects, R connection API retroactive made private R-core processx uses connection class now manage standard output error process. encoding standard output error can specified now, processx re-encodes stdout stderr UTF-8. Cloning process objects disables now, likely causes problems (@wch). supervise option kill child process R crashes (@wch). Add get_output_file get_error_file, has_output_connection() has_error_connection() methods (@wch). stdout stderr default NULL now, .e. discarded (@wch). Fix undefined behavior stdout/stderr read process already finalized, Unix. run(): Better message interruption, kill process interrupted. Unix: better kill count unloading package. Unix: make wait() work SIGCHLD delivered reason. Unix: close inherited file descriptors conservatively. Fix race condition several memory leaks Windows. Fixes running job control allow breaking away job, Windows.","code":""},{"path":"http://processx.r-lib.org/dev/news/index.html","id":"processx-2001","dir":"Changelog","previous_headings":"","what":"processx 2.0.0.1","title":"processx 2.0.0.1","text":"CRAN release: 2017-07-30 unofficial release, created CRAN, fix compilation Solaris.","code":""},{"path":"http://processx.r-lib.org/dev/news/index.html","id":"processx-200","dir":"Changelog","previous_headings":"","what":"processx 2.0.0","title":"processx 2.0.0","text":"CRAN release: 2017-05-30 First public release.","code":""}] +[{"path":[]},{"path":"http://processx.r-lib.org/dev/CODE_OF_CONDUCT.html","id":"our-pledge","dir":"","previous_headings":"","what":"Our Pledge","title":"Contributor Covenant Code of Conduct","text":"members, contributors, leaders pledge make participation community harassment-free experience everyone, regardless age, body size, visible invisible disability, ethnicity, sex characteristics, gender identity expression, level experience, education, socio-economic status, nationality, personal appearance, race, caste, color, religion, sexual identity orientation. pledge act interact ways contribute open, welcoming, diverse, inclusive, healthy community.","code":""},{"path":"http://processx.r-lib.org/dev/CODE_OF_CONDUCT.html","id":"our-standards","dir":"","previous_headings":"","what":"Our Standards","title":"Contributor Covenant Code of Conduct","text":"Examples behavior contributes positive environment community include: Demonstrating empathy kindness toward people respectful differing opinions, viewpoints, experiences Giving gracefully accepting constructive feedback Accepting responsibility apologizing affected mistakes, learning experience Focusing best just us individuals, overall community Examples unacceptable behavior include: use sexualized language imagery, sexual attention advances kind Trolling, insulting derogatory comments, personal political attacks Public private harassment Publishing others’ private information, physical email address, without explicit permission conduct reasonably considered inappropriate professional setting","code":""},{"path":"http://processx.r-lib.org/dev/CODE_OF_CONDUCT.html","id":"enforcement-responsibilities","dir":"","previous_headings":"","what":"Enforcement Responsibilities","title":"Contributor Covenant Code of Conduct","text":"Community leaders responsible clarifying enforcing standards acceptable behavior take appropriate fair corrective action response behavior deem inappropriate, threatening, offensive, harmful. Community leaders right responsibility remove, edit, reject comments, commits, code, wiki edits, issues, contributions aligned Code Conduct, communicate reasons moderation decisions appropriate.","code":""},{"path":"http://processx.r-lib.org/dev/CODE_OF_CONDUCT.html","id":"scope","dir":"","previous_headings":"","what":"Scope","title":"Contributor Covenant Code of Conduct","text":"Code Conduct applies within community spaces, also applies individual officially representing community public spaces. Examples representing community include using official e-mail address, posting via official social media account, acting appointed representative online offline event.","code":""},{"path":"http://processx.r-lib.org/dev/CODE_OF_CONDUCT.html","id":"enforcement","dir":"","previous_headings":"","what":"Enforcement","title":"Contributor Covenant Code of Conduct","text":"Instances abusive, harassing, otherwise unacceptable behavior may reported community leaders responsible enforcement codeofconduct@posit.co. complaints reviewed investigated promptly fairly. community leaders obligated respect privacy security reporter incident.","code":""},{"path":"http://processx.r-lib.org/dev/CODE_OF_CONDUCT.html","id":"enforcement-guidelines","dir":"","previous_headings":"","what":"Enforcement Guidelines","title":"Contributor Covenant Code of Conduct","text":"Community leaders follow Community Impact Guidelines determining consequences action deem violation Code Conduct:","code":""},{"path":"http://processx.r-lib.org/dev/CODE_OF_CONDUCT.html","id":"id_1-correction","dir":"","previous_headings":"Enforcement Guidelines","what":"1. Correction","title":"Contributor Covenant Code of Conduct","text":"Community Impact: Use inappropriate language behavior deemed unprofessional unwelcome community. Consequence: private, written warning community leaders, providing clarity around nature violation explanation behavior inappropriate. public apology may requested.","code":""},{"path":"http://processx.r-lib.org/dev/CODE_OF_CONDUCT.html","id":"id_2-warning","dir":"","previous_headings":"Enforcement Guidelines","what":"2. Warning","title":"Contributor Covenant Code of Conduct","text":"Community Impact: violation single incident series actions. Consequence: warning consequences continued behavior. interaction people involved, including unsolicited interaction enforcing Code Conduct, specified period time. includes avoiding interactions community spaces well external channels like social media. Violating terms may lead temporary permanent ban.","code":""},{"path":"http://processx.r-lib.org/dev/CODE_OF_CONDUCT.html","id":"id_3-temporary-ban","dir":"","previous_headings":"Enforcement Guidelines","what":"3. Temporary Ban","title":"Contributor Covenant Code of Conduct","text":"Community Impact: serious violation community standards, including sustained inappropriate behavior. Consequence: temporary ban sort interaction public communication community specified period time. public private interaction people involved, including unsolicited interaction enforcing Code Conduct, allowed period. Violating terms may lead permanent ban.","code":""},{"path":"http://processx.r-lib.org/dev/CODE_OF_CONDUCT.html","id":"id_4-permanent-ban","dir":"","previous_headings":"Enforcement Guidelines","what":"4. Permanent Ban","title":"Contributor Covenant Code of Conduct","text":"Community Impact: Demonstrating pattern violation community standards, including sustained inappropriate behavior, harassment individual, aggression toward disparagement classes individuals. Consequence: permanent ban sort public interaction within community.","code":""},{"path":"http://processx.r-lib.org/dev/CODE_OF_CONDUCT.html","id":"attribution","dir":"","previous_headings":"","what":"Attribution","title":"Contributor Covenant Code of Conduct","text":"Code Conduct adapted Contributor Covenant, version 2.1, available https://www.contributor-covenant.org/version/2/1/code_of_conduct.html. Community Impact Guidelines inspired [Mozilla’s code conduct enforcement ladder][https://github.com/mozilla/inclusion]. answers common questions code conduct, see FAQ https://www.contributor-covenant.org/faq. Translations available https://www.contributor-covenant.org/translations.","code":""},{"path":"http://processx.r-lib.org/dev/LICENSE.html","id":null,"dir":"","previous_headings":"","what":"MIT License","title":"MIT License","text":"Copyright (c) 2023 processx authors Permission hereby granted, free charge, person obtaining copy software associated documentation files (“Software”), deal Software without restriction, including without limitation rights use, copy, modify, merge, publish, distribute, sublicense, /sell copies Software, permit persons Software furnished , subject following conditions: copyright notice permission notice shall included copies substantial portions Software. SOFTWARE PROVIDED “”, WITHOUT WARRANTY KIND, EXPRESS IMPLIED, INCLUDING LIMITED WARRANTIES MERCHANTABILITY, FITNESS PARTICULAR PURPOSE NONINFRINGEMENT. EVENT SHALL AUTHORS COPYRIGHT HOLDERS LIABLE CLAIM, DAMAGES LIABILITY, WHETHER ACTION CONTRACT, TORT OTHERWISE, ARISING , CONNECTION SOFTWARE USE DEALINGS SOFTWARE.","code":""},{"path":[]},{"path":"http://processx.r-lib.org/dev/articles/internals.html","id":"unix-fifos","dir":"Articles","previous_headings":"FIFOs","what":"Unix FIFOs","title":"processx internals","text":"Unix FIFO interprocess communication device star-topology. (’s right, FIFO can multiple readers writers.) entry file system, although time data FIFO never written disk. Unix FIFO operations: Creating FIFO file system. mkfifo(2) system call. Opening FIFO. open(2). Polling FIFO. use normal poll(2) everything else. Reading FIFO. read(2). Writing FIFO. write(2) friends. Closing FIFO. close(2).","code":""},{"path":"http://processx.r-lib.org/dev/articles/internals.html","id":"blocking-vs-non-blocking-mode","dir":"Articles","previous_headings":"FIFOs","what":"Blocking vs Non-blocking mode","title":"processx internals","text":"processx functions support opening FIFO blocking non-blocking mode. Blocking mode useful open() block side FIFO open()-d least one process. cumbersome ensure can often lead deadlocks. E.g. process fails start connect FIFO, block fovever. Blocking processx FIFOs tested well, unless noted otherwise document non-blocking FIFOs.","code":""},{"path":"http://processx.r-lib.org/dev/articles/internals.html","id":"processxs-fifos-on-unix","dir":"Articles","previous_headings":"FIFOs","what":"processx’s FIFOs on Unix","title":"processx internals","text":"conn_create_fifo() first creates FIFO mkfifo(2) (1 ) opens open(2) (2 ). read = TRUE reader end (reader end, really), write = TRUE writer. writer end, need open non-blocking FIFOs read-write, otherwise open() fails FIFO reader. Weird, Unix. Even weirder, according POSIX, opening FIFO read-write mode undefined behavior. Linux documented behavior O_RDWR succeeds even reader (well, now). Apparently, also bevarios macOS. Many people say internet, standard behavior Unix systems. conn_connect_fifo() connects existing FIFO using open(2) (2 ). (Created processx .) Just like conn_create_fifo() opens FIFO read-write mode instead write-mode. helps situations FIFO file exists reader connected (yet). Unix conn_connect_fifo() fails FIFO file exist, permissions open specified mode. rest operations (3-6 ) usual processx connection operations, nothing special FIFO connections opened.","code":""},{"path":"http://processx.r-lib.org/dev/articles/internals.html","id":"emulating-fifos-with-named-pipes-on-windows","dir":"Articles","previous_headings":"FIFOs","what":"Emulating FIFOs with named pipes on Windows","title":"processx internals","text":"Windows quite equivalent FIFOs, can reasonably emulate named pipes. conn_create_fifo() creates named pipe CreateNamedPipeA() specified name. corresponds creating FIFO opening (1-2 ). conn_connect_fifo() opens named pipe, like regular file, CreateFileA() (2 ). opened, FIFOs work like regular connections. Well, mostly. See notes known platform differences !","code":""},{"path":[]},{"path":"http://processx.r-lib.org/dev/articles/internals.html","id":"how-to-check-if-the-other-write-end-of-the-fifo-is-connected","dir":"Articles","previous_headings":"FIFOs > How-to","what":"How to check if the other write-end of the FIFO is connected?","title":"processx internals","text":"read end, use poll() see data FIFO. way know currently end connects, writes data, poll() return ready .","code":""},{"path":"http://processx.r-lib.org/dev/articles/internals.html","id":"how-to-check-if-the-other-read-end-of-the-fifo-is-connected","dir":"Articles","previous_headings":"FIFOs > How-to","what":"How to check if the other read-end of the FIFO is connected?","title":"processx internals","text":"write end, unfortunately easy way make sure end connected. can try write FIFO, Unix might succeed, Windows might fail. need make sure reader end, ’ll need another FIFO opposite direction, reader can send message connected. (way communicate .) admittedly great, make much difficult use FIFOs.","code":""},{"path":"http://processx.r-lib.org/dev/articles/internals.html","id":"how-to-check-for-end-of-fifo","dir":"Articles","previous_headings":"FIFOs > How-to","what":"How to check for end-of-FIFO?","title":"processx internals","text":"usual. non-blocking read returns zero bytes data writers connected FIFO. Unix maybe writers later, processx care . connection set EOF, EOF. conn_is_incomplete() returns FALSE EOF set. (usual, makes sense check read().","code":""},{"path":"http://processx.r-lib.org/dev/articles/internals.html","id":"how-to-communicate-with-another-process","dir":"Articles","previous_headings":"FIFOs > How-to","what":"How to communicate with another process?","title":"processx internals","text":"Create FIFO conn_create_fifo() pass name FIFO (can use conn_file_name() program. piece text, can pass argument. (watch special characters, especially Windows. best use processx avoid system.) program can open FIFO (reading writing) regular file open(), fopen(), CreateFile(), etc. can open blocking non-blocking mode, needed. need bidirectional communication, use two FIFOs.","code":""},{"path":"http://processx.r-lib.org/dev/articles/internals.html","id":"platform-differences-and-portable-code","dir":"Articles","previous_headings":"FIFOs","what":"Platform differences and portable code","title":"processx internals","text":"See also “Known issues” . connect one reader one writer FIFO. fine Unix, pretty cool, actually, fail Windows. Remember zero readers writers FIFO, end signal EOF next read (poll!) operation. conn_read_*() fail Windows end FIFO connected. Always use poll() first read returns ready. poll() return ready end FIFO connected. conn_write() may fail (Windows) end FIFO connected yet also writers. (always happen, e.g. opened FIFO read-write mode first place!) prepared every conn_write() call can fail. usual conn_write() might able write data pipe/FIFO buffer full, return un-written raw() data. Make sure check return value conn_write(). poll() FIFO can return ready data next conn_read_*(), least Windows. first poll() (Windows) need start asynchronous operation waiting end pipe connect. returns, poll() signal ready, might data read just yet.","code":""},{"path":"http://processx.r-lib.org/dev/articles/internals.html","id":"known-issues","dir":"Articles","previous_headings":"FIFOs","what":"Known issues","title":"processx internals","text":"poll() FIFO might return writer end (writers) close FIFO. poll() return ready read operation, writer closed end. seems macOS bug, really bad. happens least macOS 12.3.1, happen Ubuntu 20.04. Non-ASCII file names pipe name currently issue. (Just like non-ASCII file name conn_create_file() !) fix . Encodings pipe traffic little tested. also fix .","code":""},{"path":"http://processx.r-lib.org/dev/articles/internals.html","id":"links","dir":"Articles","previous_headings":"FIFOs","what":"Links","title":"processx internals","text":"Linux fifo(7) manual page Windows CreateNamedPipeA() manual page","code":""},{"path":[]},{"path":"http://processx.r-lib.org/dev/articles/internals.html","id":"introduction","dir":"Articles","previous_headings":"Unix Domain Sockets","what":"Introduction","title":"processx internals","text":"processx functions perform IPC (inter process communication) processes running machine, using Unix domain sockets. Windows uses named pipes emulate Unix domain sockets, much possible. Unix domain sockets solve many issues FIFOs (processx FIFOs FIFOs general) , suggest use sockets instead FIFOs can.","code":""},{"path":"http://processx.r-lib.org/dev/articles/internals.html","id":"api","dir":"Articles","previous_headings":"Unix Domain Sockets","what":"API","title":"processx internals","text":"processx Unix sockets always bi-directional. conn_create_unix_socket() creates server side socket. conn_connect_unix_socket() creates client side connects server socket. call block, returns, server side accepted connection yet, probably. can still use client socket reading writing, see . can use poll() wait client connect server. client available, poll() returns \"connect\" . client available, call conn_accept_unix_socket() accept . accepting client, can send messages conn_write() read messages conn_read_chars() conn_read_lines() general use server socket read-write processx connection. server call conn_read_*() conn_write() accepting connection, calls error. client can call conn_read_*() conn_write() soon connected. Reading functions return data, conn_write() succeed, internal buffer gets full. (server accepts connection starts reading data buffer). can also use poll() wait incoming data. poll() uses read-side connections, server client. currently way poll write-sides. processx Unix socket connections non-blocking. conn_create_unix_socket(), conn_connect_unix_socket(), conn_accept_unix_socket() non-blocking well. conn_unix_socket_state() return current state socket: listen server socket calling conn_accept_unix_socket() connected_server server socket accepted client connected_client connected client close() closes socket. (read-end write-end.)","code":""},{"path":"http://processx.r-lib.org/dev/articles/internals.html","id":"file-names","dir":"Articles","previous_headings":"Unix Domain Sockets","what":"File names","title":"processx internals","text":"Unix, socket entry file system. default created R temporary directory. Windows, use named pipe emulate socket. user can specify name pipe, random name used \\\\?\\pipe\\ namespace. specify pipe name Windows, starts string processx uses . can use conn_file_name() query full path socket Unix, full name pipe Windows.","code":""},{"path":[]},{"path":"http://processx.r-lib.org/dev/articles/internals.html","id":"how-to-check-if-the-other-end-of-the-socket-is-connected","dir":"Articles","previous_headings":"Unix Domain Sockets > How-to","what":"How to check if the other end of the socket is connected?","title":"processx internals","text":"server socket can poll() client connection. client can assume connected, needs handle case conn_write() write data. (usual every non-blocking processx connection.)","code":""},{"path":"http://processx.r-lib.org/dev/articles/internals.html","id":"how-to-check-for-the-end-of-the-connection","dir":"Articles","previous_headings":"Unix Domain Sockets > How-to","what":"How to check for the end of the connection?","title":"processx internals","text":"usual. poll() return ready end closes connection. can call conn_is_incomplete() right read() see end closed connection. conn_write() error side closed connection.","code":""},{"path":"http://processx.r-lib.org/dev/articles/internals.html","id":"how-to-communicate-with-another-process-1","dir":"Articles","previous_headings":"Unix Domain Sockets > How-to","what":"How to communicate with another process?","title":"processx internals","text":"Pass socket (pipe) name . E.g. can pass command line argument. Note, however passing special file name named pipe might work older Windows systems, might want pass last component path, append \\\\?\\pipe\\ process. See sock.c src/tools example. process R process can load processx, can use processx socket functions connect socket communicate. process R process, load processx, can include include/processx/unix-socket.{c,h} files project connect socket communicate. (write C/C++ code based .) Include .c file exactly one compilation unit program, include .h file others. files portable, blocking Unix socket implementation, simple API: functions blocking, except last one, return -1 error, set errno Unix, can use GetLastError() Windows. can also use processx_socket_error_message() query system error message portable way. function returns pointer error message static buffer, copy need . Note also thread-safe. R package can use unix-socket.{c,h} via LinkingTo entry DESCRIPTION, need specify write similarly .c file:","code":"int processx_socket_connect(const char *filename, processx_socket_t *pxsocket); ssize_t processx_socket_read(processx_socket_t *pxsocket, void *buf, size_t nbyte); ssize_t processx_socket_write(processx_socket_t *pxsocket, void *buf, size_t nbyte); int processx_socket_close(processx_socket_t *pxsocket); const char* processx_socket_error_message(); LinkingTo: processx #include #include "},{"path":"http://processx.r-lib.org/dev/articles/internals.html","id":"known-issues-1","dir":"Articles","previous_headings":"Unix Domain Sockets","what":"Known issues","title":"processx internals","text":"Non-ASCII socket file names pipe name currently issue. (Just like non-ASCII file name conn_create_file() !) Encodings traffic little tested.","code":""},{"path":"http://processx.r-lib.org/dev/authors.html","id":null,"dir":"","previous_headings":"","what":"Authors","title":"Authors and Citation","text":"Gábor Csárdi. Author, maintainer, copyright holder. Winston Chang. Author. . Copyright holder, funder. Ascent Digital Services. Copyright holder, funder.","code":""},{"path":"http://processx.r-lib.org/dev/authors.html","id":"citation","dir":"","previous_headings":"","what":"Citation","title":"Authors and Citation","text":"Csárdi G, Chang W (2025). processx: Execute Control System Processes. R package version 3.8.4.9000, https://github.com/r-lib/processx, https://processx.r-lib.org.","code":"@Manual{, title = {processx: Execute and Control System Processes}, author = {Gábor Csárdi and Winston Chang}, year = {2025}, note = {R package version 3.8.4.9000, https://github.com/r-lib/processx}, url = {https://processx.r-lib.org}, }"},{"path":"http://processx.r-lib.org/dev/index.html","id":"processx","dir":"","previous_headings":"","what":"Execute and Control System Processes","title":"Execute and Control System Processes","text":"Execute Control System Processes Tools run system processes background, read standard output error kill . processx can poll standard output error single process, multiple processes, using operating system’s polling waiting facilities, timeout. Features Installation Errors Showing output Spinner Callbacks /O Starting processes Killing process Standard output error End output Polling standard output error Polling multiple processes Waiting process Exit statuses Mixing processx parallel base R package Errors Related tools Code Conduct License","code":""},{"path":"http://processx.r-lib.org/dev/index.html","id":"features","dir":"","previous_headings":"","what":"Features","title":"Execute and Control System Processes","text":"Start system processes background find process id. Read standard output error, using non-blocking connections Poll standard output error connections single process multiple processes. Write standard input background processes. Check background process running. Wait background process, multiple processes, timeout. Get exit status background process, already finished. Kill background processes. Kill background process, associated object garbage collected. Kill background processes child processes. Works Linux, macOS Windows. Lightweight, depends also lightweight R6 ps packages.","code":""},{"path":"http://processx.r-lib.org/dev/index.html","id":"installation","dir":"","previous_headings":"","what":"Installation","title":"Execute and Control System Processes","text":"Install stable version CRAN: need development version, install GitHub:","code":"install.packages(\"processx\") pak::pak(\"r-lib/processx\")"},{"path":"http://processx.r-lib.org/dev/index.html","id":"usage","dir":"","previous_headings":"","what":"Usage","title":"Execute and Control System Processes","text":"Note: following external commands usually present macOS Linux systems, necessarily Windows. also use px command line tool (px.exe Windows), simple program can produce output stdout stderr, specified timings.","code":"library(processx) px <- paste0( system.file(package = \"processx\", \"bin\", \"px\"), system.file(package = \"processx\", \"bin\", .Platform$r_arch, \"px.exe\") ) px #> [1] \"/Users/gaborcsardi/Library/R/arm64/4.2/library/processx/bin/px\""},{"path":"http://processx.r-lib.org/dev/index.html","id":"running-an-external-process","dir":"","previous_headings":"Usage","what":"Running an external process","title":"Execute and Control System Processes","text":"run() function runs external command. requires single command, character vector arguments. don’t need quote command arguments, passed directly operating system, without intermediate shell. Short summary px binary using extensively : Note: version 3.0.1, processx let specify full shell command line, involves starting grandchild process child process, difficult clean grandchild process child process killed. user can still start shell (sh cmd.exe) directly course, proper cleanup user’s responsibility.","code":"run(\"echo\", \"Hello R!\") #> $status #> [1] 0 #> #> $stdout #> [1] \"Hello R!\\n\" #> #> $stderr #> [1] \"\" #> #> $timeout #> [1] FALSE result <- run(px, \"--help\", echo = TRUE) #> Usage: px [command arg] [command arg] ... #> #> Commands: #> sleep -- sleep for a number os seconds #> out -- print string to stdout #> err -- print string to stderr #> outln -- print string to stdout, add newline #> errln -- print string to stderr, add newline #> errflush -- flush stderr stream #> cat -- print file to stdout #> return -- return with exitcode #> writefile -- write to file #> write -- write to file descriptor #> echo -- echo from fd to another fd #> getenv -- environment variable to stdout"},{"path":"http://processx.r-lib.org/dev/index.html","id":"errors","dir":"","previous_headings":"Usage > Running an external process","what":"Errors","title":"Execute and Control System Processes","text":"default run() throws error process exits non-zero status code. avoid , specify error_on_status = FALSE:","code":"run(px, c(\"out\", \"oh no!\", \"return\", \"2\"), error_on_status = FALSE) #> $status #> [1] 2 #> #> $stdout #> [1] \"oh no!\" #> #> $stderr #> [1] \"\" #> #> $timeout #> [1] FALSE"},{"path":"http://processx.r-lib.org/dev/index.html","id":"showing-output","dir":"","previous_headings":"Usage > Running an external process","what":"Showing output","title":"Execute and Control System Processes","text":"show output process screen, use echo argument. Note order stdout stderr lines may incorrect, coming two different connections. terminal support ANSI colors, standard error output shown red. standard output error still included result run() call: Note run() different system(), always shows output process R’s proper standard output, instead writing terminal directly. means example can capture output capture.output() use sink(), etc.:","code":"result <- run(px, c(\"outln\", \"out\", \"errln\", \"err\", \"outln\", \"out again\"), echo = TRUE) #> out #> out again #> err result #> $status #> [1] 0 #> #> $stdout #> [1] \"out\\nout again\\n\" #> #> $stderr #> [1] \"err\\n\" #> #> $timeout #> [1] FALSE out1 <- capture.output(r1 <- system(\"ls\")) out2 <- capture.output(r2 <- run(\"ls\", echo = TRUE)) out1 #> character(0) out2 #> [1] \"CODE_OF_CONDUCT.md\" \"DESCRIPTION\" \"LICENSE\" #> [4] \"LICENSE.md\" \"Makefile\" \"NAMESPACE\" #> [7] \"NEWS.md\" \"R\" \"README.Rmd\" #> [10] \"README.md\" \"_pkgdown.yml\" \"codecov.yml\" #> [13] \"inst\" \"man\" \"processx.Rproj\" #> [16] \"src\" \"tests\""},{"path":"http://processx.r-lib.org/dev/index.html","id":"spinner","dir":"","previous_headings":"Usage > Running an external process","what":"Spinner","title":"Execute and Control System Processes","text":"spinner option run() puts calming spinner terminal background program running. spinner always shown first character last line, can make work nicely regular output background process like. E.g. try R terminal:","code":"result <- run(px, c(\"out\", \" foo\", \"sleep\", \"1\", \"out\", \"\\r bar\", \"sleep\", \"1\", \"out\", \"\\rX foobar\\n\"), echo = TRUE, spinner = TRUE)"},{"path":"http://processx.r-lib.org/dev/index.html","id":"callbacks-for-io","dir":"","previous_headings":"Usage > Running an external process","what":"Callbacks for I/O","title":"Execute and Control System Processes","text":"run() can call R function line standard output error process, just supply stdout_line_callback stderr_line_callback arguments. callback functions take two arguments, first one character scalar, output line. second one process object represents background process. (See process objects.) can manipulate object callback, want. example can kill response error text standard output: Keep mind, R callback running, background process stopped, also running. previous example, whether still printed depends scheduling R process background process OS. Typically, printed, R callback takes run. addition line-oriented callbacks, stdout_callback stderr_callback arguments can specify callback functions called output chunks instead single lines. chunk may contain multiple lines (separated \\n \\r\\n), even incomplete lines.","code":"cb <- function(line, proc) { cat(\"Got:\", line, \"\\n\") if (line == \"done\") proc$kill() } result <- run(px, c(\"outln\", \"this\", \"outln\", \"that\", \"outln\", \"done\", \"outln\", \"still here\", \"sleep\", \"10\", \"outln\", \"dead by now\"), stdout_line_callback = cb, error_on_status = FALSE, ) #> Got: this #> Got: that #> Got: done #> Got: still here result #> $status #> [1] -9 #> #> $stdout #> [1] \"this\\nthat\\ndone\\nstill here\\n\" #> #> $stderr #> [1] \"\" #> #> $timeout #> [1] FALSE"},{"path":"http://processx.r-lib.org/dev/index.html","id":"managing-external-processes","dir":"","previous_headings":"Usage","what":"Managing external processes","title":"Execute and Control System Processes","text":"need better control possibly multiple background processes, can use R6 process class directly.","code":""},{"path":"http://processx.r-lib.org/dev/index.html","id":"starting-processes","dir":"","previous_headings":"Usage > Managing external processes","what":"Starting processes","title":"Execute and Control System Processes","text":"start new background process, create new instance process class.","code":"p <- process$new(\"sleep\", \"20\")"},{"path":"http://processx.r-lib.org/dev/index.html","id":"killing-a-process","dir":"","previous_headings":"Usage > Managing external processes","what":"Killing a process","title":"Execute and Control System Processes","text":"process can killed via kill() method. Note processes finalized (killed) automatically corresponding process object goes scope, soon object garbage collected R: , direct call garbage collector kills sleep process well. See cleanup option want avoid behavior.","code":"p$is_alive() #> [1] TRUE p$kill() #> [1] TRUE p$is_alive() #> [1] FALSE p <- process$new(\"sleep\", \"20\") rm(p) invisible(gc())"},{"path":"http://processx.r-lib.org/dev/index.html","id":"standard-output-and-error","dir":"","previous_headings":"Usage > Managing external processes","what":"Standard output and error","title":"Execute and Control System Processes","text":"default standard output error processes ignored. can set stdout stderr constructor arguments file name, redirected , \"|\", processx creates connections . (Note starting processx 3.0.0 connections regular R connections, public R connection API retroactively removed R.) read_output_lines() read_error_lines() methods can used read complete lines standard output error connections. work similarly readLines() base R function. Note, connections buffer, can fill , R read output, process stop, R reads connection buffer freed. Always make sure read standard output /error pipes, otherwise background process stop running! don’t need standard output error , can also close , like : Note connections used reading output error streams non-blocking, read functions return immediately, even text read . want make sure data available read, need poll, see .","code":"close(p$get_output_connection()) close(p$get_error_connection()) p <- process$new(px, c(\"sleep\", \"1\", \"outln\", \"foo\", \"errln\", \"bar\", \"outln\", \"foobar\"), stdout = \"|\", stderr = \"|\") p$read_output_lines() #> character(0) p$read_error_lines() #> character(0)"},{"path":"http://processx.r-lib.org/dev/index.html","id":"end-of-output","dir":"","previous_headings":"Usage > Managing external processes","what":"End of output","title":"Execute and Control System Processes","text":"standard R way query end stream non-blocking connection, use isIncomplete() function. read attempt, function returns FALSE connection surely data. (read attempt returns data, isIncomplete() returns TRUE, connection might deliver data future. is_incomplete_output() is_incomplete_error() functions work similarly process objects.","code":""},{"path":"http://processx.r-lib.org/dev/index.html","id":"polling-the-standard-output-and-error","dir":"","previous_headings":"Usage > Managing external processes","what":"Polling the standard output and error","title":"Execute and Control System Processes","text":"poll_io() method waits data standard output /error process. return following events happen: data available standard output process (assuming connection standard output). data available standard error process (assuming connection standard error). process finished standard output /error connections closed end. specified timeout period expired. example following code waits second output.","code":"p <- process$new(px, c(\"sleep\", \"1\", \"outln\", \"kuku\"), stdout = \"|\") ## No output yet p$read_output_lines() #> character(0) ## Wait at most 5 sec p$poll_io(5000) #> output error process #> \"ready\" \"nopipe\" \"nopipe\" ## There is output now p$read_output_lines() #> [1] \"kuku\""},{"path":"http://processx.r-lib.org/dev/index.html","id":"polling-multiple-processes","dir":"","previous_headings":"Usage > Managing external processes","what":"Polling multiple processes","title":"Execute and Control System Processes","text":"need manage multiple background processes, need wait output , processx defines poll() function just . similar poll_io() method, takes multiple process objects, returns soon one data standard output error, timeout expires. example:","code":"p1 <- process$new(px, c(\"sleep\", \"1\", \"outln\", \"output\"), stdout = \"|\") p2 <- process$new(px, c(\"sleep\", \"2\", \"errln\", \"error\"), stderr = \"|\") ## After 100ms no output yet poll(list(p1 = p1, p2 = p2), 100) #> $p1 #> output error process #> \"timeout\" \"nopipe\" \"nopipe\" #> #> $p2 #> output error process #> \"nopipe\" \"timeout\" \"nopipe\" ## But now we surely have something poll(list(p1 = p1, p2 = p2), 1000) #> $p1 #> output error process #> \"ready\" \"nopipe\" \"nopipe\" #> #> $p2 #> output error process #> \"nopipe\" \"silent\" \"nopipe\" p1$read_output_lines() #> [1] \"output\" ## Done with p1 close(p1$get_output_connection()) #> NULL ## The second process should have data on stderr soonish poll(list(p1 = p1, p2 = p2), 5000) #> $p1 #> output error process #> \"closed\" \"nopipe\" \"nopipe\" #> #> $p2 #> output error process #> \"nopipe\" \"ready\" \"nopipe\" p2$read_error_lines() #> [1] \"error\""},{"path":"http://processx.r-lib.org/dev/index.html","id":"waiting-on-a-process","dir":"","previous_headings":"Usage > Managing external processes","what":"Waiting on a process","title":"Execute and Control System Processes","text":"seen , is_alive() checks process running. wait() method can used wait finished (specified timeout expires).. E.g. following code wait() needs wait 2 seconds sleep px command finish. safe call wait() multiple times:","code":"p <- process$new(px, c(\"sleep\", \"2\")) p$is_alive() #> [1] TRUE Sys.time() #> [1] \"2022-06-10 13:57:49 CEST\" p$wait() Sys.time() #> [1] \"2022-06-10 13:57:51 CEST\" p$wait() # already finished!"},{"path":"http://processx.r-lib.org/dev/index.html","id":"exit-statuses","dir":"","previous_headings":"Usage > Managing external processes","what":"Exit statuses","title":"Execute and Control System Processes","text":"process finished, exit status can queried via get_exit_status() method. process still running, method returns NULL.","code":"p <- process$new(px, c(\"sleep\", \"2\")) p$get_exit_status() #> NULL p$wait() p$get_exit_status() #> [1] 0"},{"path":"http://processx.r-lib.org/dev/index.html","id":"mixing-processx-and-the-parallel-base-r-package","dir":"","previous_headings":"Usage > Managing external processes","what":"Mixing processx and the parallel base R package","title":"Execute and Control System Processes","text":"general, mixing processx (via callr ) parallel works fine. use parallel’s ‘fork’ clusters, e.g. via parallel::mcparallel(), might see two issues. One processx able determine exit status processx processes. status read parallel, processx set NA. one parallel might complain clean subprocesses. error, harmless, hold R 10 seconds, parallel gives . work around , can set PROCESSX_NOTIFY_OLD_SIGCHLD environment variable non-empty value, load processx. behavior might default future.","code":""},{"path":"http://processx.r-lib.org/dev/index.html","id":"errors-1","dir":"","previous_headings":"Usage > Managing external processes","what":"Errors","title":"Execute and Control System Processes","text":"Errors typically signalled via non-zero exits statuses. processx constructor fails external program started, deal errors happen program successfully started running.","code":"p <- process$new(\"nonexistant-command-for-sure\") #> Error in c(\"process_initialize(self, private, command, args, stdin, stdout, \", : ! Native call to `processx_exec` failed #> Caused by error in `chain_call(c_processx_exec, command, c(command, args), pty, pty_options, …` at initialize.R:138:3: #> ! cannot start processx process 'nonexistant-command-for-sure' (system error 2, No such file or directory) @unix/processx.c:613 (processx_exec) p2 <- process$new(px, c(\"sleep\", \"1\", \"command-does-not-exist\")) p2$wait() p2$get_exit_status() #> [1] 5"},{"path":"http://processx.r-lib.org/dev/index.html","id":"related-tools","dir":"","previous_headings":"","what":"Related tools","title":"Execute and Control System Processes","text":"ps package can query, list, manipulate system processes (just subprocesses), processx uses internally functionality. can also convert processx::process object ps::ps_handle as_ps_handle() method. callr package uses processx start another R process, run R code , foreground background.","code":""},{"path":"http://processx.r-lib.org/dev/index.html","id":"code-of-conduct","dir":"","previous_headings":"","what":"Code of Conduct","title":"Execute and Control System Processes","text":"Please note processx project released Contributor Code Conduct. contributing project, agree abide terms.","code":""},{"path":"http://processx.r-lib.org/dev/index.html","id":"license","dir":"","previous_headings":"","what":"License","title":"Execute and Control System Processes","text":"MIT © Ascent Digital Services, RStudio, Gábor Csárdi","code":""},{"path":"http://processx.r-lib.org/dev/reference/base64_decode.html","id":null,"dir":"Reference","previous_headings":"","what":"Base64 Encoding and Decoding — base64_decode","title":"Base64 Encoding and Decoding — base64_decode","text":"Base64 Encoding Decoding","code":""},{"path":"http://processx.r-lib.org/dev/reference/base64_decode.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Base64 Encoding and Decoding — base64_decode","text":"","code":"base64_decode(x) base64_encode(x)"},{"path":"http://processx.r-lib.org/dev/reference/base64_decode.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Base64 Encoding and Decoding — base64_decode","text":"x Raw vector encode / decode.","code":""},{"path":"http://processx.r-lib.org/dev/reference/base64_decode.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Base64 Encoding and Decoding — base64_decode","text":"Raw vector, result encoding / decoding.","code":""},{"path":"http://processx.r-lib.org/dev/reference/curl_fds.html","id":null,"dir":"Reference","previous_headings":"","what":"Create a pollable object from a curl multi handle's file descriptors — curl_fds","title":"Create a pollable object from a curl multi handle's file descriptors — curl_fds","text":"Create pollable object curl multi handle's file descriptors","code":""},{"path":"http://processx.r-lib.org/dev/reference/curl_fds.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Create a pollable object from a curl multi handle's file descriptors — curl_fds","text":"","code":"curl_fds(fds)"},{"path":"http://processx.r-lib.org/dev/reference/curl_fds.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Create a pollable object from a curl multi handle's file descriptors — curl_fds","text":"fds list file descriptors, returned curl::multi_fdset().","code":""},{"path":"http://processx.r-lib.org/dev/reference/curl_fds.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Create a pollable object from a curl multi handle's file descriptors — curl_fds","text":"Pollable object, used poll() directly.","code":""},{"path":"http://processx.r-lib.org/dev/reference/default_pty_options.html","id":null,"dir":"Reference","previous_headings":"","what":"Default options for pseudo terminals (ptys) — default_pty_options","title":"Default options for pseudo terminals (ptys) — default_pty_options","text":"Default options pseudo terminals (ptys)","code":""},{"path":"http://processx.r-lib.org/dev/reference/default_pty_options.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Default options for pseudo terminals (ptys) — default_pty_options","text":"","code":"default_pty_options()"},{"path":"http://processx.r-lib.org/dev/reference/default_pty_options.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Default options for pseudo terminals (ptys) — default_pty_options","text":"Named list default values pty options. Options default values: echo whether keep echo terminal. FALSE turns echo . rows (initial) terminal size, number rows. cols (initial) terminal size, number columns.","code":""},{"path":"http://processx.r-lib.org/dev/reference/poll.html","id":null,"dir":"Reference","previous_headings":"","what":"Poll for process I/O or termination — poll","title":"Poll for process I/O or termination — poll","text":"Wait one specified connections processes produce standard output error, terminates, timeout occurs.","code":""},{"path":"http://processx.r-lib.org/dev/reference/poll.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Poll for process I/O or termination — poll","text":"","code":"poll(processes, ms)"},{"path":"http://processx.r-lib.org/dev/reference/poll.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Poll for process I/O or termination — poll","text":"processes list connection objects orprocess objects wait . (can mixed well.) named list, returned list names. simplifies identification processes. ms Integer scalar, timeout polling, milliseconds. Supply -1 infitite timeout, 0 waiting .","code":""},{"path":"http://processx.r-lib.org/dev/reference/poll.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Poll for process I/O or termination — poll","text":"list character vectors length one three. one list element connection/process, order input list. connections result single string scalar. processes character vectors' elements named output, error process. Possible values individual result : nopipe, ready, timeout, closed, silent. See details . process refers poll connection, see poll_connection argument process initializer.","code":""},{"path":"http://processx.r-lib.org/dev/reference/poll.html","id":"explanation-of-the-return-values","dir":"Reference","previous_headings":"","what":"Explanation of the return values","title":"Poll for process I/O or termination — poll","text":"nopipe means stdout stderr process captured. ready means connection stdout stderr process ready read . Note end--file outputs also triggers ready. timeout`: connections processes ready read timeout happened. closed: connection already closed, polling started. silent: connection ready read , another connection .","code":""},{"path":"http://processx.r-lib.org/dev/reference/poll.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Poll for process I/O or termination — poll","text":"","code":"if (FALSE) { # Different commands to run for windows and unix cmd1 <- switch( .Platform$OS.type, \"unix\" = c(\"sh\", \"-c\", \"sleep 1; ls\"), c(\"cmd\", \"/c\", \"ping -n 2 127.0.0.1 && dir /b\") ) cmd2 <- switch( .Platform$OS.type, \"unix\" = c(\"sh\", \"-c\", \"sleep 2; ls 1>&2\"), c(\"cmd\", \"/c\", \"ping -n 2 127.0.0.1 && dir /b 1>&2\") ) ## Run them. p1 writes to stdout, p2 to stderr, after some sleep p1 <- process$new(cmd1[1], cmd1[-1], stdout = \"|\") p2 <- process$new(cmd2[1], cmd2[-1], stderr = \"|\") ## Nothing to read initially poll(list(p1 = p1, p2 = p2), 0) ## Wait until p1 finishes. Now p1 has some output p1$wait() poll(list(p1 = p1, p2 = p2), -1) ## Close p1's connection, p2 will have output on stderr, eventually close(p1$get_output_connection()) poll(list(p1 = p1, p2 = p2), -1) ## Close p2's connection as well, no nothing to poll close(p2$get_error_connection()) poll(list(p1 = p1, p2 = p2), 0) }"},{"path":"http://processx.r-lib.org/dev/reference/process.html","id":null,"dir":"Reference","previous_headings":"","what":"External process — process","title":"External process — process","text":"Managing external processes R trivial, class aims help deficiency. essentially small wrapper around system base R function, return process id started process, set standard output error streams. process id used manage process.","code":""},{"path":"http://processx.r-lib.org/dev/reference/process.html","id":"batch-files","dir":"Reference","previous_headings":"","what":"Batch files","title":"External process — process","text":"Running Windows batch files (.bat .cmd files) may complicated cmd.exe command line parsing rules. example easily whitespace command (path) one arguments. work around limitations need start cmd.exe shell explicitly use call command. example: works even bat_file contains whitespace characters. information , see processx issue: https://github.com/r-lib/processx/issues/301 detailed parsing rules https://docs.microsoft.com/en-us/windows-server/administration/windows-commands/cmd good practical guide https://ss64.com/nt/syntax-esc.html","code":"process$new(\"cmd.exe\", c(\"/c\", \"call\", bat_file, \"arg 1\", \"arg 2\"))"},{"path":"http://processx.r-lib.org/dev/reference/process.html","id":"polling","dir":"Reference","previous_headings":"","what":"Polling","title":"External process — process","text":"poll_io() function polls standard output standard error connections process, timeout. output either , closed (e.g. process exits) poll_io() returns immediately. addition polling single process, poll() function can poll output several processes, returns soon generated output (exited).","code":""},{"path":"http://processx.r-lib.org/dev/reference/process.html","id":"cleaning-up-background-processes","dir":"Reference","previous_headings":"","what":"Cleaning up background processes","title":"External process — process","text":"processx kills processes referenced (cleanup set TRUE), whole subprocess tree (cleanup_tree also set TRUE). cleanup happens references processes object garbage collected. clean earlier, can call kill() kill_tree() method process(es), .exit() expression, error handler: interrupt process_manager() error happens p1 p2 cleaned immediately. connections also closed. happens regular exit.","code":"process_manager <- function() { on.exit({ try(p1$kill(), silent = TRUE) try(p2$kill(), silent = TRUE) }, add = TRUE) p1 <- process$new(\"sleep\", \"3\") p2 <- process$new(\"sleep\", \"10\") p1$wait() p2$wait() } process_manager()"},{"path":[]},{"path":"http://processx.r-lib.org/dev/reference/process.html","id":"public-methods","dir":"Reference","previous_headings":"","what":"Public methods","title":"External process — process","text":"process$new() process$finalize() process$kill() process$kill_tree() process$signal() process$interrupt() process$get_pid() process$is_alive() process$wait() process$get_exit_status() process$format() process$print() process$get_start_time() process$is_supervised() process$supervise() process$read_output() process$read_error() process$read_output_lines() process$read_error_lines() process$is_incomplete_output() process$is_incomplete_error() process$has_input_connection() process$has_output_connection() process$has_error_connection() process$has_poll_connection() process$get_input_connection() process$get_output_connection() process$get_error_connection() process$read_all_output() process$read_all_error() process$read_all_output_lines() process$read_all_error_lines() process$write_input() process$get_input_file() process$get_output_file() process$get_error_file() process$poll_io() process$get_poll_connection() process$get_result() process$as_ps_handle() process$get_name() process$get_exe() process$get_cmdline() process$get_status() process$get_username() process$get_wd() process$get_cpu_times() process$get_memory_info() process$suspend() process$resume()","code":""},{"path":"http://processx.r-lib.org/dev/reference/process.html","id":"method-new-","dir":"Reference","previous_headings":"","what":"Method new()","title":"External process — process","text":"Start new process background, return immediately.","code":""},{"path":"http://processx.r-lib.org/dev/reference/process.html","id":"usage","dir":"Reference","previous_headings":"","what":"Usage","title":"External process — process","text":"","code":"process$new( command = NULL, args = character(), stdin = NULL, stdout = NULL, stderr = NULL, pty = FALSE, pty_options = list(), connections = list(), poll_connection = NULL, env = NULL, cleanup = TRUE, cleanup_tree = FALSE, wd = NULL, echo_cmd = FALSE, supervise = FALSE, windows_verbatim_args = FALSE, windows_hide_window = FALSE, windows_detached_process = !cleanup, encoding = \"\", post_process = NULL )"},{"path":"http://processx.r-lib.org/dev/reference/process.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"External process — process","text":"command Character scalar, command run. Note argument passed shell, tilde-expansion variable substitution performed . quoted base::shQuote(). See base::normalizePath() tilde-expansion. want run .bat .cmd files Windows, make sure read 'Batch files' section . args Character vector, arguments command. passed process , without shell transforming , need escaped. stdin standard input. Possible values: NULL: set null device, .e. standard input provided; file name, use file standard input; \"|\": create (writeable) connection stdin. \"\" (empty string): inherit main R process. main R process standard input stream, e.g. RGui Windows, error thrown. stdout standard output. Possible values: NULL: discard ; string, redirect file. Note specify relative path, relative current working directory, even specify another directory wd argument. (See issue 324.) \"|\": create connection . \"\" (empty string): inherit main R process. main R process standard output stream, e.g. RGui Windows, error thrown. stderr standard error. Possible values: NULL: discard . string, redirect file. Note specify relative path, relative current working directory, even specify another directory wd argument. (See issue 324.) \"|\": create connection . \"2>&1\": redirect connection (.e. pipe file) stdout. \"2>&1\" way keep standard output error correctly interleaved. \"\" (empty string): inherit main R process. main R process standard error stream, e.g. RGui Windows, error thrown. pty Whether create pseudo terminal (pty) background process. currently supported Unix systems, supported Solaris. TRUE, stdin, stdout stderr arguments must NULL. pseudo terminal created, processx create pipes standard input standard output. separate pipe standard error, way distinguish stdout stderr pty. Note standard output connection pty blocking, always poll standard output connection reading using $read_output() method. Also, $read_output_lines() still block complete line available, function always fails process pty. Use $read_output() read ptys. pty_options Unix pseudo terminal options, named list. see default_pty_options() details defaults. connections list processx connections pass child process. experimental feature currently. poll_connection Whether create extra connection process allows polling, even standard input standard output pipes. NULL (default), connection created standard output standard error pipes, connections empty list. poll connection created, can query via p$get_poll_connection() also included response p$poll_io() poll(). numeric file descriptor poll connection comes right stderr (2), connections listed connections. env Environment variables child process. NULL, parent's environment inherited. Windows, many programs function correctly environment variables set, always set HOMEDRIVE, HOMEPATH, LOGONSERVER, PATH, SYSTEMDRIVE, SYSTEMROOT, TEMP, USERDOMAIN, USERNAME, USERPROFILE WINDIR. append new environment variables ones set current process, specify \"current\" env, without name, appended ones names. appended ones can overwrite current ones. cleanup Whether kill process process object garbage collected. cleanup_tree Whether kill process child process tree process object garbage collected. wd Working directory process. must exist. NULL, current working directory used. echo_cmd Whether print command screen running . supervise Whether register process supervisor. TRUE, supervisor ensure process killed R process exits. windows_verbatim_args Whether omit quoting arguments Windows. ignored platforms. windows_hide_window Whether hide application's window Windows. ignored platforms. windows_detached_process Whether use DETACHED_PROCESS flag Windows. TRUE, child process attached console, even parent one. encoding encoding assume stdin, stdout stderr. default encoding current locale used. Note processx always reencodes output stdout stderr streams UTF-8 currently. want read without conversion, platforms, specify \"UTF-8\" encoding. post_process optional function run process finished. Currently runs $get_result() called. run .","code":""},{"path":"http://processx.r-lib.org/dev/reference/process.html","id":"returns","dir":"Reference","previous_headings":"","what":"Returns","title":"External process — process","text":"R6 object representing process.","code":""},{"path":"http://processx.r-lib.org/dev/reference/process.html","id":"method-finalize-","dir":"Reference","previous_headings":"","what":"Method finalize()","title":"External process — process","text":"Cleanup method called process object garbage collected. requested process constructor, eliminates processes process's subprocess tree.","code":""},{"path":"http://processx.r-lib.org/dev/reference/process.html","id":"usage-1","dir":"Reference","previous_headings":"","what":"Usage","title":"External process — process","text":"","code":"process$finalize()"},{"path":"http://processx.r-lib.org/dev/reference/process.html","id":"method-kill-","dir":"Reference","previous_headings":"","what":"Method kill()","title":"External process — process","text":"Terminate process. also terminate child processes, except created new process group (Unix), job object (Windows). returns TRUE process terminated, FALSE (already finished/dead processx tried terminate ).","code":""},{"path":"http://processx.r-lib.org/dev/reference/process.html","id":"usage-2","dir":"Reference","previous_headings":"","what":"Usage","title":"External process — process","text":"","code":"process$kill(grace = 0.1, close_connections = TRUE)"},{"path":"http://processx.r-lib.org/dev/reference/process.html","id":"arguments-1","dir":"Reference","previous_headings":"","what":"Arguments","title":"External process — process","text":"grace Currently used. close_connections Whether close standard input, standard output, standard error connections poll connection, killing process.","code":""},{"path":"http://processx.r-lib.org/dev/reference/process.html","id":"method-kill-tree-","dir":"Reference","previous_headings":"","what":"Method kill_tree()","title":"External process — process","text":"Process tree cleanup. terminates process (still alive), together child (grandchild, etc.) processes. uses ps package, needs installed, ps needs support current platform well. Process tree cleanup works marking process environment variable, inherited child processes. allows finding descendents, even orphaned, .e. connected root tree cleanup process tree . $kill_tree() returns named integer vector process ids killed, names names processes (e.g. \"sleep\", \"notepad.exe\", \"Rterm.exe\", etc.).","code":""},{"path":"http://processx.r-lib.org/dev/reference/process.html","id":"usage-3","dir":"Reference","previous_headings":"","what":"Usage","title":"External process — process","text":"","code":"process$kill_tree(grace = 0.1, close_connections = TRUE)"},{"path":"http://processx.r-lib.org/dev/reference/process.html","id":"arguments-2","dir":"Reference","previous_headings":"","what":"Arguments","title":"External process — process","text":"grace Currently used. close_connections Whether close standard input, standard output, standard error connections poll connection, killing process.","code":""},{"path":"http://processx.r-lib.org/dev/reference/process.html","id":"method-signal-","dir":"Reference","previous_headings":"","what":"Method signal()","title":"External process — process","text":"Send signal process. Windows SIGINT, SIGTERM SIGKILL signals interpreted, special 0 signal. first three kill process. 0 signal returns TRUE process alive, FALSE otherwise. Unix signals supported OS supports, 0 signal well.","code":""},{"path":"http://processx.r-lib.org/dev/reference/process.html","id":"usage-4","dir":"Reference","previous_headings":"","what":"Usage","title":"External process — process","text":"","code":"process$signal(signal)"},{"path":"http://processx.r-lib.org/dev/reference/process.html","id":"arguments-3","dir":"Reference","previous_headings":"","what":"Arguments","title":"External process — process","text":"signal integer scalar, id signal send process. See tools::pskill() list signals.","code":""},{"path":"http://processx.r-lib.org/dev/reference/process.html","id":"method-interrupt-","dir":"Reference","previous_headings":"","what":"Method interrupt()","title":"External process — process","text":"Send interrupt process. Unix SIGINT signal, usually equivalent pressing CTRL+C terminal prompt. Windows, CTRL+BREAK keypress. Applications may catch events. default quit.","code":""},{"path":"http://processx.r-lib.org/dev/reference/process.html","id":"usage-5","dir":"Reference","previous_headings":"","what":"Usage","title":"External process — process","text":"","code":"process$interrupt()"},{"path":"http://processx.r-lib.org/dev/reference/process.html","id":"method-get-pid-","dir":"Reference","previous_headings":"","what":"Method get_pid()","title":"External process — process","text":"Query process id.","code":""},{"path":"http://processx.r-lib.org/dev/reference/process.html","id":"usage-6","dir":"Reference","previous_headings":"","what":"Usage","title":"External process — process","text":"","code":"process$get_pid()"},{"path":"http://processx.r-lib.org/dev/reference/process.html","id":"returns-1","dir":"Reference","previous_headings":"","what":"Returns","title":"External process — process","text":"Integer scalar, process id process.","code":""},{"path":"http://processx.r-lib.org/dev/reference/process.html","id":"method-is-alive-","dir":"Reference","previous_headings":"","what":"Method is_alive()","title":"External process — process","text":"Check process alive.","code":""},{"path":"http://processx.r-lib.org/dev/reference/process.html","id":"usage-7","dir":"Reference","previous_headings":"","what":"Usage","title":"External process — process","text":"","code":"process$is_alive()"},{"path":"http://processx.r-lib.org/dev/reference/process.html","id":"returns-2","dir":"Reference","previous_headings":"","what":"Returns","title":"External process — process","text":"Logical scalar.","code":""},{"path":"http://processx.r-lib.org/dev/reference/process.html","id":"method-wait-","dir":"Reference","previous_headings":"","what":"Method wait()","title":"External process — process","text":"Wait process finishes, timeout happens. Note process never finishes, timeout infinite (default), R never regain control. rare cases, $wait() might take bit longer specified time . happens Unix, another package overwrites processx SIGCHLD signal handler, processx process started. One package parallel, used fork clusters, e.g. parallel::mcparallel().","code":""},{"path":"http://processx.r-lib.org/dev/reference/process.html","id":"usage-8","dir":"Reference","previous_headings":"","what":"Usage","title":"External process — process","text":"","code":"process$wait(timeout = -1)"},{"path":"http://processx.r-lib.org/dev/reference/process.html","id":"arguments-4","dir":"Reference","previous_headings":"","what":"Arguments","title":"External process — process","text":"timeout Timeout milliseconds, wait /O polling.","code":""},{"path":"http://processx.r-lib.org/dev/reference/process.html","id":"returns-3","dir":"Reference","previous_headings":"","what":"Returns","title":"External process — process","text":"returns process , invisibly.","code":""},{"path":"http://processx.r-lib.org/dev/reference/process.html","id":"method-get-exit-status-","dir":"Reference","previous_headings":"","what":"Method get_exit_status()","title":"External process — process","text":"$get_exit_status returns exit code process finished NULL otherwise. Unix, rare cases, exit status might NA. happens another package (R ) overwrites processx SIGCHLD handler, processx process started. cases processx determine real exit status process. One package parallel, used fork clusters, e.g. parallel::mcparallel() function.","code":""},{"path":"http://processx.r-lib.org/dev/reference/process.html","id":"usage-9","dir":"Reference","previous_headings":"","what":"Usage","title":"External process — process","text":"","code":"process$get_exit_status()"},{"path":"http://processx.r-lib.org/dev/reference/process.html","id":"method-format-","dir":"Reference","previous_headings":"","what":"Method format()","title":"External process — process","text":"format(p) p$format() creates string representation process, usually printing.","code":""},{"path":"http://processx.r-lib.org/dev/reference/process.html","id":"usage-10","dir":"Reference","previous_headings":"","what":"Usage","title":"External process — process","text":"","code":"process$format()"},{"path":"http://processx.r-lib.org/dev/reference/process.html","id":"method-print-","dir":"Reference","previous_headings":"","what":"Method print()","title":"External process — process","text":"print(p) p$print() shows information process screen, whether running process id, etc.","code":""},{"path":"http://processx.r-lib.org/dev/reference/process.html","id":"usage-11","dir":"Reference","previous_headings":"","what":"Usage","title":"External process — process","text":"","code":"process$print()"},{"path":"http://processx.r-lib.org/dev/reference/process.html","id":"method-get-start-time-","dir":"Reference","previous_headings":"","what":"Method get_start_time()","title":"External process — process","text":"$get_start_time() returns time process started.","code":""},{"path":"http://processx.r-lib.org/dev/reference/process.html","id":"usage-12","dir":"Reference","previous_headings":"","what":"Usage","title":"External process — process","text":"","code":"process$get_start_time()"},{"path":"http://processx.r-lib.org/dev/reference/process.html","id":"method-is-supervised-","dir":"Reference","previous_headings":"","what":"Method is_supervised()","title":"External process — process","text":"$is_supervised() returns whether process tracked supervisor process.","code":""},{"path":"http://processx.r-lib.org/dev/reference/process.html","id":"usage-13","dir":"Reference","previous_headings":"","what":"Usage","title":"External process — process","text":"","code":"process$is_supervised()"},{"path":"http://processx.r-lib.org/dev/reference/process.html","id":"method-supervise-","dir":"Reference","previous_headings":"","what":"Method supervise()","title":"External process — process","text":"$supervise() passed TRUE, tells supervisor start tracking process. FALSE, tells supervisor stop tracking process. Note even supervisor disabled process, started cleanup = TRUE, process still killed object garbage collected.","code":""},{"path":"http://processx.r-lib.org/dev/reference/process.html","id":"usage-14","dir":"Reference","previous_headings":"","what":"Usage","title":"External process — process","text":"","code":"process$supervise(status)"},{"path":"http://processx.r-lib.org/dev/reference/process.html","id":"arguments-5","dir":"Reference","previous_headings":"","what":"Arguments","title":"External process — process","text":"status Whether turn supervisor process.","code":""},{"path":"http://processx.r-lib.org/dev/reference/process.html","id":"method-read-output-","dir":"Reference","previous_headings":"","what":"Method read_output()","title":"External process — process","text":"$read_output() reads standard output connection process. standard output connection requested, returns error. uses non-blocking text connection. work stdout=\"|\" used. Otherwise, throw error.","code":""},{"path":"http://processx.r-lib.org/dev/reference/process.html","id":"usage-15","dir":"Reference","previous_headings":"","what":"Usage","title":"External process — process","text":"","code":"process$read_output(n = -1)"},{"path":"http://processx.r-lib.org/dev/reference/process.html","id":"arguments-6","dir":"Reference","previous_headings":"","what":"Arguments","title":"External process — process","text":"n Number characters lines read.","code":""},{"path":"http://processx.r-lib.org/dev/reference/process.html","id":"method-read-error-","dir":"Reference","previous_headings":"","what":"Method read_error()","title":"External process — process","text":"$read_error() similar $read_output, reads standard error stream.","code":""},{"path":"http://processx.r-lib.org/dev/reference/process.html","id":"usage-16","dir":"Reference","previous_headings":"","what":"Usage","title":"External process — process","text":"","code":"process$read_error(n = -1)"},{"path":"http://processx.r-lib.org/dev/reference/process.html","id":"arguments-7","dir":"Reference","previous_headings":"","what":"Arguments","title":"External process — process","text":"n Number characters lines read.","code":""},{"path":"http://processx.r-lib.org/dev/reference/process.html","id":"method-read-output-lines-","dir":"Reference","previous_headings":"","what":"Method read_output_lines()","title":"External process — process","text":"$read_output_lines() reads lines standard output connection process. standard output connection requested, returns error. uses non-blocking text connection. work stdout=\"|\" used. Otherwise, throw error.","code":""},{"path":"http://processx.r-lib.org/dev/reference/process.html","id":"usage-17","dir":"Reference","previous_headings":"","what":"Usage","title":"External process — process","text":"","code":"process$read_output_lines(n = -1)"},{"path":"http://processx.r-lib.org/dev/reference/process.html","id":"arguments-8","dir":"Reference","previous_headings":"","what":"Arguments","title":"External process — process","text":"n Number characters lines read.","code":""},{"path":"http://processx.r-lib.org/dev/reference/process.html","id":"method-read-error-lines-","dir":"Reference","previous_headings":"","what":"Method read_error_lines()","title":"External process — process","text":"$read_error_lines() similar $read_output_lines, reads standard error stream.","code":""},{"path":"http://processx.r-lib.org/dev/reference/process.html","id":"usage-18","dir":"Reference","previous_headings":"","what":"Usage","title":"External process — process","text":"","code":"process$read_error_lines(n = -1)"},{"path":"http://processx.r-lib.org/dev/reference/process.html","id":"arguments-9","dir":"Reference","previous_headings":"","what":"Arguments","title":"External process — process","text":"n Number characters lines read.","code":""},{"path":"http://processx.r-lib.org/dev/reference/process.html","id":"method-is-incomplete-output-","dir":"Reference","previous_headings":"","what":"Method is_incomplete_output()","title":"External process — process","text":"$is_incomplete_output() return FALSE end standard output connection closed (probably process exited). return TRUE otherwise.","code":""},{"path":"http://processx.r-lib.org/dev/reference/process.html","id":"usage-19","dir":"Reference","previous_headings":"","what":"Usage","title":"External process — process","text":"","code":"process$is_incomplete_output()"},{"path":"http://processx.r-lib.org/dev/reference/process.html","id":"method-is-incomplete-error-","dir":"Reference","previous_headings":"","what":"Method is_incomplete_error()","title":"External process — process","text":"$is_incomplete_error() return FALSE end standard error connection closed (probably process exited). return TRUE otherwise.","code":""},{"path":"http://processx.r-lib.org/dev/reference/process.html","id":"usage-20","dir":"Reference","previous_headings":"","what":"Usage","title":"External process — process","text":"","code":"process$is_incomplete_error()"},{"path":"http://processx.r-lib.org/dev/reference/process.html","id":"method-has-input-connection-","dir":"Reference","previous_headings":"","what":"Method has_input_connection()","title":"External process — process","text":"$has_input_connection() return TRUE connection object standard input; words, stdout=\"|\". returns FALSE otherwise.","code":""},{"path":"http://processx.r-lib.org/dev/reference/process.html","id":"usage-21","dir":"Reference","previous_headings":"","what":"Usage","title":"External process — process","text":"","code":"process$has_input_connection()"},{"path":"http://processx.r-lib.org/dev/reference/process.html","id":"method-has-output-connection-","dir":"Reference","previous_headings":"","what":"Method has_output_connection()","title":"External process — process","text":"$has_output_connection() returns TRUE connection object standard output; words, stdout=\"|\". returns FALSE otherwise.","code":""},{"path":"http://processx.r-lib.org/dev/reference/process.html","id":"usage-22","dir":"Reference","previous_headings":"","what":"Usage","title":"External process — process","text":"","code":"process$has_output_connection()"},{"path":"http://processx.r-lib.org/dev/reference/process.html","id":"method-has-error-connection-","dir":"Reference","previous_headings":"","what":"Method has_error_connection()","title":"External process — process","text":"$has_error_connection() returns TRUE connection object standard error; words, stderr=\"|\". returns FALSE otherwise.","code":""},{"path":"http://processx.r-lib.org/dev/reference/process.html","id":"usage-23","dir":"Reference","previous_headings":"","what":"Usage","title":"External process — process","text":"","code":"process$has_error_connection()"},{"path":"http://processx.r-lib.org/dev/reference/process.html","id":"method-has-poll-connection-","dir":"Reference","previous_headings":"","what":"Method has_poll_connection()","title":"External process — process","text":"$has_poll_connection() return TRUE poll connection, FALSE otherwise.","code":""},{"path":"http://processx.r-lib.org/dev/reference/process.html","id":"usage-24","dir":"Reference","previous_headings":"","what":"Usage","title":"External process — process","text":"","code":"process$has_poll_connection()"},{"path":"http://processx.r-lib.org/dev/reference/process.html","id":"method-get-input-connection-","dir":"Reference","previous_headings":"","what":"Method get_input_connection()","title":"External process — process","text":"$get_input_connection() returns connection object, standard input stream process.","code":""},{"path":"http://processx.r-lib.org/dev/reference/process.html","id":"usage-25","dir":"Reference","previous_headings":"","what":"Usage","title":"External process — process","text":"","code":"process$get_input_connection()"},{"path":"http://processx.r-lib.org/dev/reference/process.html","id":"method-get-output-connection-","dir":"Reference","previous_headings":"","what":"Method get_output_connection()","title":"External process — process","text":"$get_output_connection() returns connection object, standard output stream process.","code":""},{"path":"http://processx.r-lib.org/dev/reference/process.html","id":"usage-26","dir":"Reference","previous_headings":"","what":"Usage","title":"External process — process","text":"","code":"process$get_output_connection()"},{"path":"http://processx.r-lib.org/dev/reference/process.html","id":"method-get-error-connection-","dir":"Reference","previous_headings":"","what":"Method get_error_connection()","title":"External process — process","text":"$get_error_conneciton() returns connection object, standard error stream process.","code":""},{"path":"http://processx.r-lib.org/dev/reference/process.html","id":"usage-27","dir":"Reference","previous_headings":"","what":"Usage","title":"External process — process","text":"","code":"process$get_error_connection()"},{"path":"http://processx.r-lib.org/dev/reference/process.html","id":"method-read-all-output-","dir":"Reference","previous_headings":"","what":"Method read_all_output()","title":"External process — process","text":"$read_all_output() waits standard output process. return process finished. Note process involves waiting process finish, polling /O potentially several readLines() calls. returns character scalar. return content stdout=\"|\" used. Otherwise, throw error.","code":""},{"path":"http://processx.r-lib.org/dev/reference/process.html","id":"usage-28","dir":"Reference","previous_headings":"","what":"Usage","title":"External process — process","text":"","code":"process$read_all_output()"},{"path":"http://processx.r-lib.org/dev/reference/process.html","id":"method-read-all-error-","dir":"Reference","previous_headings":"","what":"Method read_all_error()","title":"External process — process","text":"$read_all_error() waits standard error process. return process finished. Note process involves waiting process finish, polling /O potentially several readLines() calls. returns character scalar. return content stderr=\"|\" used. Otherwise, throw error.","code":""},{"path":"http://processx.r-lib.org/dev/reference/process.html","id":"usage-29","dir":"Reference","previous_headings":"","what":"Usage","title":"External process — process","text":"","code":"process$read_all_error()"},{"path":"http://processx.r-lib.org/dev/reference/process.html","id":"method-read-all-output-lines-","dir":"Reference","previous_headings":"","what":"Method read_all_output_lines()","title":"External process — process","text":"$read_all_output_lines() waits standard output lines process. return process finished. Note process involves waiting process finish, polling /O potentially several readLines() calls. returns character vector. return content stdout=\"|\" used. Otherwise, throw error.","code":""},{"path":"http://processx.r-lib.org/dev/reference/process.html","id":"usage-30","dir":"Reference","previous_headings":"","what":"Usage","title":"External process — process","text":"","code":"process$read_all_output_lines()"},{"path":"http://processx.r-lib.org/dev/reference/process.html","id":"method-read-all-error-lines-","dir":"Reference","previous_headings":"","what":"Method read_all_error_lines()","title":"External process — process","text":"$read_all_error_lines() waits standard error lines process. return process finished. Note process involves waiting process finish, polling /O potentially several readLines() calls. returns character vector. return content stderr=\"|\" used. Otherwise, throw error.","code":""},{"path":"http://processx.r-lib.org/dev/reference/process.html","id":"usage-31","dir":"Reference","previous_headings":"","what":"Usage","title":"External process — process","text":"","code":"process$read_all_error_lines()"},{"path":"http://processx.r-lib.org/dev/reference/process.html","id":"method-write-input-","dir":"Reference","previous_headings":"","what":"Method write_input()","title":"External process — process","text":"$write_input() writes character vector (separated sep) standard input process. converted specified encoding. operation non-blocking, return, even write fails (write buffer full), suceeds partially (.e. full string written). returns raw vector, contains bytes written. can supply raw vector $write_input() , fully written, return value raw(0) (invisibly).","code":""},{"path":"http://processx.r-lib.org/dev/reference/process.html","id":"usage-32","dir":"Reference","previous_headings":"","what":"Usage","title":"External process — process","text":"","code":"process$write_input(str, sep = \"\\n\")"},{"path":"http://processx.r-lib.org/dev/reference/process.html","id":"arguments-10","dir":"Reference","previous_headings":"","what":"Arguments","title":"External process — process","text":"str Character raw vector write standard input process. character vector marked encoding, converted encoding. sep Separator add str elements character vector. ignored str raw vector.","code":""},{"path":"http://processx.r-lib.org/dev/reference/process.html","id":"returns-4","dir":"Reference","previous_headings":"","what":"Returns","title":"External process — process","text":"Leftover text (raw vector), written.","code":""},{"path":"http://processx.r-lib.org/dev/reference/process.html","id":"method-get-input-file-","dir":"Reference","previous_headings":"","what":"Method get_input_file()","title":"External process — process","text":"$get_input_file() stdin argument filename, returns absolute path file. stdin \"|\" NULL, simply returns value.","code":""},{"path":"http://processx.r-lib.org/dev/reference/process.html","id":"usage-33","dir":"Reference","previous_headings":"","what":"Usage","title":"External process — process","text":"","code":"process$get_input_file()"},{"path":"http://processx.r-lib.org/dev/reference/process.html","id":"method-get-output-file-","dir":"Reference","previous_headings":"","what":"Method get_output_file()","title":"External process — process","text":"$get_output_file() stdout argument filename, returns absolute path file. stdout \"|\" NULL, simply returns value.","code":""},{"path":"http://processx.r-lib.org/dev/reference/process.html","id":"usage-34","dir":"Reference","previous_headings":"","what":"Usage","title":"External process — process","text":"","code":"process$get_output_file()"},{"path":"http://processx.r-lib.org/dev/reference/process.html","id":"method-get-error-file-","dir":"Reference","previous_headings":"","what":"Method get_error_file()","title":"External process — process","text":"$get_error_file() stderr argument filename, returns absolute path file. stderr \"|\" NULL, simply returns value.","code":""},{"path":"http://processx.r-lib.org/dev/reference/process.html","id":"usage-35","dir":"Reference","previous_headings":"","what":"Usage","title":"External process — process","text":"","code":"process$get_error_file()"},{"path":"http://processx.r-lib.org/dev/reference/process.html","id":"method-poll-io-","dir":"Reference","previous_headings":"","what":"Method poll_io()","title":"External process — process","text":"$poll_io() polls process's connections /O. See Polling section, see also poll() function poll multiple processes.","code":""},{"path":"http://processx.r-lib.org/dev/reference/process.html","id":"usage-36","dir":"Reference","previous_headings":"","what":"Usage","title":"External process — process","text":"","code":"process$poll_io(timeout)"},{"path":"http://processx.r-lib.org/dev/reference/process.html","id":"arguments-11","dir":"Reference","previous_headings":"","what":"Arguments","title":"External process — process","text":"timeout Timeout milliseconds, wait /O polling.","code":""},{"path":"http://processx.r-lib.org/dev/reference/process.html","id":"method-get-poll-connection-","dir":"Reference","previous_headings":"","what":"Method get_poll_connection()","title":"External process — process","text":"$get_poll_connetion() returns poll connection, process one.","code":""},{"path":"http://processx.r-lib.org/dev/reference/process.html","id":"usage-37","dir":"Reference","previous_headings":"","what":"Usage","title":"External process — process","text":"","code":"process$get_poll_connection()"},{"path":"http://processx.r-lib.org/dev/reference/process.html","id":"method-get-result-","dir":"Reference","previous_headings":"","what":"Method get_result()","title":"External process — process","text":"$get_result() returns result post processesing function. can called process finished. process post-processing function, NULL returned.","code":""},{"path":"http://processx.r-lib.org/dev/reference/process.html","id":"usage-38","dir":"Reference","previous_headings":"","what":"Usage","title":"External process — process","text":"","code":"process$get_result()"},{"path":"http://processx.r-lib.org/dev/reference/process.html","id":"method-as-ps-handle-","dir":"Reference","previous_headings":"","what":"Method as_ps_handle()","title":"External process — process","text":"$as_ps_handle() returns ps::ps_handle object, corresponding process.","code":""},{"path":"http://processx.r-lib.org/dev/reference/process.html","id":"usage-39","dir":"Reference","previous_headings":"","what":"Usage","title":"External process — process","text":"","code":"process$as_ps_handle()"},{"path":"http://processx.r-lib.org/dev/reference/process.html","id":"method-get-name-","dir":"Reference","previous_headings":"","what":"Method get_name()","title":"External process — process","text":"Calls ps::ps_name() get process name.","code":""},{"path":"http://processx.r-lib.org/dev/reference/process.html","id":"usage-40","dir":"Reference","previous_headings":"","what":"Usage","title":"External process — process","text":"","code":"process$get_name()"},{"path":"http://processx.r-lib.org/dev/reference/process.html","id":"method-get-exe-","dir":"Reference","previous_headings":"","what":"Method get_exe()","title":"External process — process","text":"Calls ps::ps_exe() get path executable.","code":""},{"path":"http://processx.r-lib.org/dev/reference/process.html","id":"usage-41","dir":"Reference","previous_headings":"","what":"Usage","title":"External process — process","text":"","code":"process$get_exe()"},{"path":"http://processx.r-lib.org/dev/reference/process.html","id":"method-get-cmdline-","dir":"Reference","previous_headings":"","what":"Method get_cmdline()","title":"External process — process","text":"Calls ps::ps_cmdline() get command line.","code":""},{"path":"http://processx.r-lib.org/dev/reference/process.html","id":"usage-42","dir":"Reference","previous_headings":"","what":"Usage","title":"External process — process","text":"","code":"process$get_cmdline()"},{"path":"http://processx.r-lib.org/dev/reference/process.html","id":"method-get-status-","dir":"Reference","previous_headings":"","what":"Method get_status()","title":"External process — process","text":"Calls ps::ps_status() get process status.","code":""},{"path":"http://processx.r-lib.org/dev/reference/process.html","id":"usage-43","dir":"Reference","previous_headings":"","what":"Usage","title":"External process — process","text":"","code":"process$get_status()"},{"path":"http://processx.r-lib.org/dev/reference/process.html","id":"method-get-username-","dir":"Reference","previous_headings":"","what":"Method get_username()","title":"External process — process","text":"calls ps::ps_username() get username.","code":""},{"path":"http://processx.r-lib.org/dev/reference/process.html","id":"usage-44","dir":"Reference","previous_headings":"","what":"Usage","title":"External process — process","text":"","code":"process$get_username()"},{"path":"http://processx.r-lib.org/dev/reference/process.html","id":"method-get-wd-","dir":"Reference","previous_headings":"","what":"Method get_wd()","title":"External process — process","text":"Calls ps::ps_cwd() get current working directory.","code":""},{"path":"http://processx.r-lib.org/dev/reference/process.html","id":"usage-45","dir":"Reference","previous_headings":"","what":"Usage","title":"External process — process","text":"","code":"process$get_wd()"},{"path":"http://processx.r-lib.org/dev/reference/process.html","id":"method-get-cpu-times-","dir":"Reference","previous_headings":"","what":"Method get_cpu_times()","title":"External process — process","text":"Calls ps::ps_cpu_times() get CPU usage data.","code":""},{"path":"http://processx.r-lib.org/dev/reference/process.html","id":"usage-46","dir":"Reference","previous_headings":"","what":"Usage","title":"External process — process","text":"","code":"process$get_cpu_times()"},{"path":"http://processx.r-lib.org/dev/reference/process.html","id":"method-get-memory-info-","dir":"Reference","previous_headings":"","what":"Method get_memory_info()","title":"External process — process","text":"Calls ps::ps_memory_info() get memory data.","code":""},{"path":"http://processx.r-lib.org/dev/reference/process.html","id":"usage-47","dir":"Reference","previous_headings":"","what":"Usage","title":"External process — process","text":"","code":"process$get_memory_info()"},{"path":"http://processx.r-lib.org/dev/reference/process.html","id":"method-suspend-","dir":"Reference","previous_headings":"","what":"Method suspend()","title":"External process — process","text":"Calls ps::ps_suspend() suspend process.","code":""},{"path":"http://processx.r-lib.org/dev/reference/process.html","id":"usage-48","dir":"Reference","previous_headings":"","what":"Usage","title":"External process — process","text":"","code":"process$suspend()"},{"path":"http://processx.r-lib.org/dev/reference/process.html","id":"method-resume-","dir":"Reference","previous_headings":"","what":"Method resume()","title":"External process — process","text":"Calls ps::ps_resume() resume suspended process.","code":""},{"path":"http://processx.r-lib.org/dev/reference/process.html","id":"usage-49","dir":"Reference","previous_headings":"","what":"Usage","title":"External process — process","text":"","code":"process$resume()"},{"path":"http://processx.r-lib.org/dev/reference/process.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"External process — process","text":"","code":"p <- process$new(\"sleep\", \"2\") p$is_alive() #> [1] TRUE p #> PROCESS 'sleep', running, pid 6366. p$kill() #> [1] TRUE p$is_alive() #> [1] FALSE p <- process$new(\"sleep\", \"1\") p$is_alive() #> [1] TRUE Sys.sleep(2) p$is_alive() #> [1] FALSE"},{"path":"http://processx.r-lib.org/dev/reference/process_initialize.html","id":null,"dir":"Reference","previous_headings":"","what":"Start a process — process_initialize","title":"Start a process — process_initialize","text":"Start process","code":""},{"path":"http://processx.r-lib.org/dev/reference/process_initialize.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Start a process — process_initialize","text":"","code":"process_initialize( self, private, command, args, stdin, stdout, stderr, pty, pty_options, connections, poll_connection, env, cleanup, cleanup_tree, wd, echo_cmd, supervise, windows_verbatim_args, windows_hide_window, windows_detached_process, encoding, post_process )"},{"path":"http://processx.r-lib.org/dev/reference/process_initialize.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Start a process — process_initialize","text":"self private $private command Command run, string scalar. args Command arguments, character vector. stdin Standard input, NULL ignore. stdout Standard output, NULL ignore, TRUE temp file. stderr Standard error, NULL ignore, TRUE temp file. pty Whether create PTY. connections Connections inherit child process. poll_connection Whether create connection polling. env Environment vaiables. cleanup Kill GC? cleanup_tree Kill process tree GC? wd working directory (NULL) echo_cmd Echo command starting ? supervise process supervised? encoding Assumed stdout stderr encoding. post_process Post processing function.","code":""},{"path":"http://processx.r-lib.org/dev/reference/processx-package.html","id":null,"dir":"Reference","previous_headings":"","what":"processx: Execute and Control System Processes — processx-package","title":"processx: Execute and Control System Processes — processx-package","text":"Tools run system processes background. can check background process running; wait background process finish; get exit status finished processes; kill background processes. can read standard output error processes, using non-blocking connections. 'processx' can poll process standard output error, timeout. can also poll several processes .","code":""},{"path":[]},{"path":"http://processx.r-lib.org/dev/reference/processx-package.html","id":"author","dir":"Reference","previous_headings":"","what":"Author","title":"processx: Execute and Control System Processes — processx-package","text":"Maintainer: Gábor Csárdi csardi.gabor@gmail.com (ORCID) [copyright holder] Authors: Winston Chang contributors: Posit Software, PBC [copyright holder, funder] Ascent Digital Services [copyright holder, funder]","code":""},{"path":"http://processx.r-lib.org/dev/reference/processx_connections.html","id":null,"dir":"Reference","previous_headings":"","what":"Processx connections — conn_create_fd","title":"Processx connections — conn_create_fd","text":"functions currently experimental change future. Note processx connections compatible R's built-connection system.","code":""},{"path":"http://processx.r-lib.org/dev/reference/processx_connections.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Processx connections — conn_create_fd","text":"","code":"conn_create_fd(fd, encoding = \"\", close = TRUE) conn_file_name(con) conn_create_pipepair(encoding = \"\", nonblocking = c(TRUE, FALSE)) conn_read_chars(con, n = -1) # S3 method for class 'processx_connection' conn_read_chars(con, n = -1) processx_conn_read_chars(con, n = -1) conn_read_lines(con, n = -1) # S3 method for class 'processx_connection' conn_read_lines(con, n = -1) processx_conn_read_lines(con, n = -1) conn_is_incomplete(con) # S3 method for class 'processx_connection' conn_is_incomplete(con) processx_conn_is_incomplete(con) conn_write(con, str, sep = \"\\n\", encoding = \"\") # S3 method for class 'processx_connection' conn_write(con, str, sep = \"\\n\", encoding = \"\") processx_conn_write(con, str, sep = \"\\n\", encoding = \"\") conn_create_file(filename, read = NULL, write = NULL) conn_set_stdout(con, drop = TRUE) conn_set_stderr(con, drop = TRUE) conn_get_fileno(con) conn_disable_inheritance() # S3 method for class 'processx_connection' close(con, ...) processx_conn_close(con, ...) is_valid_fd(fd)"},{"path":"http://processx.r-lib.org/dev/reference/processx_connections.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Processx connections — conn_create_fd","text":"fd Integer scalar, Unix file descriptor. encoding Encoding readable connection reading. close Whether close OS file descriptor closing connection. Sometimes want leave open, use conn_create_fd call. Encoding re-encode str writing. con Processx connection object. nonblocking Whether pipe non-blocking. conn_create_pipepair() must logical vector length two, ends pipe. n Number characters lines read. -1 means available characters lines. str Character raw vector write. sep Separator use str character vector. Ignored str raw vector. filename File name. conn_create_pipe() Windows, \\\\?\\pipe prefix added , prefix. conn_create_pipe() can also NULL, case random file name used via tempfile(). read Whether connection readable. write Whethe connection writeable. drop Whether close original stdout/stderr, keep open return connection . ... Extra arguments, compatibility close() generic, currently ignored processx.","code":""},{"path":"http://processx.r-lib.org/dev/reference/processx_connections.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Processx connections — conn_create_fd","text":"conn_create_fd() creates connection file descriptor. conn_file_name() returns name file associated connection. connections refer file file system returns NA_character(). Except named pipes Windows, returns full name pipe. conn_create_pipepair() creates pair connected connections, first one writeable, second one readable. conn_read_chars() reads UTF-8 characters connections. connection UTF-8 encoded, re-encodes . conn_read_lines() reads lines connection. conn_is_incomplete() returns FALSE connection surely data. conn_write() writes character raw vector connection. might able write bytes connection, case returns leftover bytes raw vector. Call conn_write() raw vector. conn_create_file() creates connection file. conn_set_stdout() set standard output R process, specified connection. conn_set_stderr() set standard error R process, specified connection. conn_get_fileno() return integer file desciptor belongs connection. conn_disable_inheritance() can called disable inheritance open handles. Call function soon possible new process avoid inheriting inherited handles even . function best effort close handles, might still leave handles open. work stdin, stdout stderr, least. is_valid_fd() returns TRUE fd valid open file descriptor. can use check R process standard input, output error. E.g. R processes running GUI (like RGui) might standard streams available. stream redirected null device (e.g. callr subprocess), still valid file descriptor.","code":""},{"path":"http://processx.r-lib.org/dev/reference/processx_connections.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Processx connections — conn_create_fd","text":"","code":"is_valid_fd(0L) # stdin #> [1] TRUE is_valid_fd(1L) # stdout #> [1] TRUE is_valid_fd(2L) # stderr #> [1] TRUE"},{"path":"http://processx.r-lib.org/dev/reference/processx_fifos.html","id":null,"dir":"Reference","previous_headings":"","what":"Processx FIFOs — conn_create_fifo","title":"Processx FIFOs — conn_create_fifo","text":"Create FIFO inter-process communication Note functions currently experimental.","code":""},{"path":"http://processx.r-lib.org/dev/reference/processx_fifos.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Processx FIFOs — conn_create_fifo","text":"","code":"conn_create_fifo( filename = NULL, read = NULL, write = NULL, encoding = \"\", nonblocking = TRUE ) conn_connect_fifo( filename, read = NULL, write = NULL, encoding = \"\", nonblocking = TRUE )"},{"path":"http://processx.r-lib.org/dev/reference/processx_fifos.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Processx FIFOs — conn_create_fifo","text":"filename File name FIFO. Windows name pipe within \\\\?\\pipe\\ namespace, either full name, part prefix. NULL, random name used, Unix R temporary directory: base::tempdir(). read TRUE connect read end FIFO. Exactly one read write must set TRUE. write TRUE connect write end FIFO. Exactly one read write must set TRUE. encoding Encoding assume. nonblocking Whether non-blocking FIFO. Note blocking FIFOs well tested might work well poll(), especially Windows. might remove option future make FIFOs non-blocking.","code":""},{"path":"http://processx.r-lib.org/dev/reference/processx_fifos.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Processx FIFOs — conn_create_fifo","text":"conn_create_fifo() creates FIFO connects . Unix proper FIFO file system, R temporary directory. Windows named pipe. Use conn_file_name() query name FIFO, conn_connect_fifo() connect end. conn_connect_fifo() connects FIFO created conn_create_fifo(), typically another process. filename refers name pipe Windows. Windows, conn_connect_fifo() may successful even FIFO exist, later poll() read/write operations fail. planning changing behavior future, make conn_connect_fifo() fail immediately, like Unix.","code":""},{"path":[]},{"path":"http://processx.r-lib.org/dev/reference/processx_fifos.html","id":"in-general-unix-domain-sockets-work-better-than-fifos-so-we-suggest","dir":"Reference","previous_headings":"","what":"In general Unix domain sockets work better than FIFOs, so we suggest","title":"Processx FIFOs — conn_create_fifo","text":"use sockets can. See conn_create_unix_socket().","code":""},{"path":"http://processx.r-lib.org/dev/reference/processx_fifos.html","id":"creating-the-read-end-of-the-fifo","dir":"Reference","previous_headings":"","what":"Creating the read end of the FIFO","title":"Processx FIFOs — conn_create_fifo","text":"case simpler. wait writer connect FIFO can use poll() usual. use conn_read_chars() conn_read_lines() read FIFO, usual. Use conn_is_incomplete() read check data, writer done.","code":""},{"path":"http://processx.r-lib.org/dev/reference/processx_fifos.html","id":"creating-the-write-end-of-the-fifo","dir":"Reference","previous_headings":"","what":"Creating the write end of the FIFO","title":"Processx FIFOs — conn_create_fifo","text":"somewhat trickier. Creating (non-blocking) FIFO block. However, easy way tell reader connected end FIFO . Unix can start using conn_write() try write , succeed, buffer gets full, even reader. (buffer full return data written, usual.) Windows, using conn_write() write FIFO without reader fails error. great, planning improve later. Right now, one workaround behavior reader connunicate writer process independenctly connected FIFO. (E.g. another FIFO opposite direction can .)","code":""},{"path":[]},{"path":"http://processx.r-lib.org/dev/reference/processx_fifos.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Processx FIFOs — conn_create_fifo","text":"","code":"# Example for a non-blocking FIFO # Need to open the reading end first, otherwise Unix fails reader <- conn_create_fifo() # Always use poll() before you read, with a timeout if you like. # If you read before the other end of the FIFO is connected, then # the OS (or processx?) assumes that the FIFO is done, and you cannot # read anything. # Now poll() tells us that there is no data yet. poll(list(reader), 0) #> [[1]] #> [1] \"timeout\" #> writer <- conn_connect_fifo(conn_file_name(reader), write = TRUE) conn_write(writer, \"hello\\nthere!\\n\") poll(list(reader), 1000) #> [[1]] #> [1] \"ready\" #> conn_read_lines(reader, 1) #> [1] \"hello\" conn_read_chars(reader) #> [1] \"there!\\n\" conn_is_incomplete(reader) #> [1] TRUE close(writer) #> NULL conn_read_chars(reader) #> [1] \"\" conn_is_incomplete(reader) #> [1] FALSE close(reader) #> NULL"},{"path":"http://processx.r-lib.org/dev/reference/processx_sockets.html","id":null,"dir":"Reference","previous_headings":"","what":"Unix domain sockets — conn_create_unix_socket","title":"Unix domain sockets — conn_create_unix_socket","text":"Cross platform point--point inter-process communication Unix=domain sockets, implemented via named pipes Windows. connection always bidirectional, .e. can read also write .","code":""},{"path":"http://processx.r-lib.org/dev/reference/processx_sockets.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Unix domain sockets — conn_create_unix_socket","text":"","code":"conn_create_unix_socket(filename = NULL, encoding = \"\") conn_connect_unix_socket(filename, encoding = \"\") conn_accept_unix_socket(con) conn_unix_socket_state(con)"},{"path":"http://processx.r-lib.org/dev/reference/processx_sockets.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Unix domain sockets — conn_create_unix_socket","text":"filename File name socket. Windows name pipe within \\\\?\\pipe\\ namespace, either full name, part prefix. NULL, random name used, Unix R temporary directory: base::tempdir(). encoding Encoding assume reading socket. con Connection. error thrown socket connection.","code":""},{"path":"http://processx.r-lib.org/dev/reference/processx_sockets.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Unix domain sockets — conn_create_unix_socket","text":"new socket connection.","code":""},{"path":"http://processx.r-lib.org/dev/reference/processx_sockets.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Unix domain sockets — conn_create_unix_socket","text":"conn_create_unix_socket() creates server socket. new socket listening filename. See filename . conn_connect_unix_socket() creates client socket connects server socket. conn_accept_unix_socket() accepts client connection server socket. conn_unix_socket_state() returns state socket. Currently can return: \"listening\", \"connected_server\", \"connected_client\". possible states (e.g. closed socket) added future.","code":""},{"path":"http://processx.r-lib.org/dev/reference/processx_sockets.html","id":"notes","dir":"Reference","previous_headings":"","what":"Notes","title":"Unix domain sockets — conn_create_unix_socket","text":"poll() works sockets, polls data read, currently ignores write-end socket. poll() also works accepting client connections. return \"connect\"client connection available server socket. can call conn_accept_unix_socket() accept client connection.","code":""},{"path":[]},{"path":"http://processx.r-lib.org/dev/reference/run.html","id":null,"dir":"Reference","previous_headings":"","what":"Run external command, and wait until finishes — run","title":"Run external command, and wait until finishes — run","text":"run provides interface similar base::system() base::system2(), based process class. allows extra features, see .","code":""},{"path":"http://processx.r-lib.org/dev/reference/run.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Run external command, and wait until finishes — run","text":"","code":"run( command = NULL, args = character(), error_on_status = TRUE, wd = NULL, echo_cmd = FALSE, echo = FALSE, spinner = FALSE, timeout = Inf, stdout = \"|\", stderr = \"|\", stdout_line_callback = NULL, stdout_callback = NULL, stderr_line_callback = NULL, stderr_callback = NULL, stderr_to_stdout = FALSE, env = NULL, windows_verbatim_args = FALSE, windows_hide_window = FALSE, encoding = \"\", cleanup_tree = FALSE, ... )"},{"path":"http://processx.r-lib.org/dev/reference/run.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Run external command, and wait until finishes — run","text":"command Character scalar, command run. running .bat .cmd files Windows, make sure read 'Batch files' section process manual page. args Character vector, arguments command. error_on_status Whether throw error command returns non-zero status, interrupted. error classes system_command_status_error system_command_timeout_error, respectively, errors class system_command_error well. See also \"Error conditions\" . wd Working directory process. NULL, current working directory used. echo_cmd Whether print command run screen. echo Whether print standard output error screen. Note order standard output error lines necessarily correct, standard output typically buffered. standard output /error redirected file ignored, also echoed. spinner Whether show reassuring spinner process running. timeout Timeout process, seconds, difftime object. finished , killed. stdout standard output. default collected result, can also use stdout_line_callback stdout_callback arguments pass callbacks output. empty string (\"\"), child process inherits standard output stream R process. (main R process standard output stream, e.g. RGui Windows, error thrown.) NULL, standard output discarded. string \"|\" \"\", taken file name output redirected file. stderr standard error. default collected result, can also use stderr_line_callback stderr_callback arguments pass callbacks output. empty string (\"\"), child process inherits standard error stream R process. (main R process standard error stream, e.g. RGui Windows, error thrown.) NULL, standard error discarded. string \"|\" \"\", taken file name standard error redirected file. stdout_line_callback NULL, function call every line standard output. See stdout_callback also . stdout_callback NULL, function call every chunk standard output. chunk can small single character. one stdout_line_callback stdout_callback can non-NULL. stderr_line_callback NULL, function call every line standard error. See stderr_callback also . stderr_callback NULL, function call every chunk standard error. chunk can small single character. one stderr_line_callback stderr_callback can non-NULL. stderr_to_stdout Whether redirect standard error standard output. Specifying TRUE keep standard output, correctly interleaved. However, possible deduce pieces output coming . TRUE, standard error callbacks () never called. env Environment variables child process. NULL, parent's environment inherited. Windows, many programs function correctly environment variables set, always set HOMEDRIVE, HOMEPATH, LOGONSERVER, PATH, SYSTEMDRIVE, SYSTEMROOT, TEMP, USERDOMAIN, USERNAME, USERPROFILE WINDIR. append new environment variables ones set current process, specify \"current\" env, without name, appended ones names. appended ones can overwrite current ones. windows_verbatim_args Whether omit escaping command arguments windows. Ignored platforms. windows_hide_window Whether hide window application windows. Ignored platforms. encoding encoding assume stdout stderr. default encoding current locale used. Note processx always reencodes output streams UTF-8 currently. cleanup_tree Whether clean child process tree process finished. ... Extra arguments passed process$new(), see process. Note pass stout stderr , used internally run(). can use stdout_callback, stderr_callback, etc. arguments manage standard output error, process class directly need flexibility.","code":""},{"path":"http://processx.r-lib.org/dev/reference/run.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Run external command, and wait until finishes — run","text":"list components: status exit status process. NA, process killed exit status. stdout standard output command, character scalar. stderr standard error command, character scalar. timeout Whether process killed timeout.","code":""},{"path":"http://processx.r-lib.org/dev/reference/run.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Run external command, and wait until finishes — run","text":"run supports Specifying timeout command. specified time passed, process still running, killed (child processes). Calling callback function line chunk standard output /error. chunk may contain multiple lines, can short single character. Cleaning subprocess, whole process tree, exiting.","code":""},{"path":"http://processx.r-lib.org/dev/reference/run.html","id":"callbacks","dir":"Reference","previous_headings":"","what":"Callbacks","title":"Run external command, and wait until finishes — run","text":"notes callback functions. first argument callback function character scalar (length 1 character), single output error line. second argument always process object. can manipulate object, example can call $kill() terminate , response message standard output error.","code":""},{"path":"http://processx.r-lib.org/dev/reference/run.html","id":"error-conditions","dir":"Reference","previous_headings":"","what":"Error conditions","title":"Run external command, and wait until finishes — run","text":"run() throws error condition objects process interrupted, timeouts fails (error_on_status TRUE): interrupt, condition classes system_command_interrupt, interrupt, condition signalled. can caught tryCatch(..., interrupt = ...). timeout, condition classes system_command_timeout_error, system_command_error, error, condition thrown. error (error_on_status TRUE), error classes system_command_status_error, system_command_error, error, condition thrown. conditions fields: message: error message, stderr: standard error process, standard output process stderr_to_stdout TRUE. call: captured call run(). echo: value echo argument. stderr_to_stdout: value stderr_to_stdout argument. status: exit status system_command_status_error errors.","code":""},{"path":"http://processx.r-lib.org/dev/reference/run.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Run external command, and wait until finishes — run","text":"","code":"# This works on Unix systems run(\"ls\") #> $status #> [1] 0 #> #> $stdout #> [1] \"base64_decode.html\\ncurl_fds.html\\ndefault_pty_options.html\\nfigures\\nindex.html\\npoll.html\\nprocess.html\\nprocess_initialize.html\\nprocessx-package.html\\nprocessx_connections.html\\nprocessx_fifos.html\\nprocessx_sockets.html\\n\" #> #> $stderr #> [1] \"\" #> #> $timeout #> [1] FALSE #> system.time(run(\"sleep\", \"10\", timeout = 1, error_on_status = FALSE)) #> user system elapsed #> 0.003 0.014 0.158 system.time( run( \"sh\", c(\"-c\", \"for i in 1 2 3 4 5; do echo $i; sleep 1; done\"), timeout = 2, error_on_status = FALSE ) ) #> user system elapsed #> 0.002 0.012 1.160 if (FALSE) { # This works on Windows systems, if the ping command is available run(\"ping\", c(\"-n\", \"1\", \"127.0.0.1\")) run(\"ping\", c(\"-n\", \"6\", \"127.0.0.1\"), timeout = 1, error_on_status = FALSE) }"},{"path":"http://processx.r-lib.org/dev/reference/supervisor_kill.html","id":null,"dir":"Reference","previous_headings":"","what":"Terminate all supervised processes and the supervisor process itself as well — supervisor_kill","title":"Terminate all supervised processes and the supervisor process itself as well — supervisor_kill","text":"Unix supervisor sends SIGTERM signal supervised processes, gives five seconds quit, sending SIGKILL signal. supervisor terminates.","code":""},{"path":"http://processx.r-lib.org/dev/reference/supervisor_kill.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Terminate all supervised processes and the supervisor process itself as well — supervisor_kill","text":"","code":"supervisor_kill()"},{"path":"http://processx.r-lib.org/dev/reference/supervisor_kill.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Terminate all supervised processes and the supervisor process itself as well — supervisor_kill","text":"Windows similar, instead SIGTERM, console CTRL+C interrupt sent first, WM_CLOSE message sent windows supervised processes, windows.","code":""},{"path":"http://processx.r-lib.org/dev/news/index.html","id":"processx-development-version","dir":"Changelog","previous_headings":"","what":"processx (development version)","title":"processx (development version)","text":"changes.","code":""},{"path":"http://processx.r-lib.org/dev/news/index.html","id":"processx-384","dir":"Changelog","previous_headings":"","what":"processx 3.8.4","title":"processx 3.8.4","text":"CRAN release: 2024-03-16 changes.","code":""},{"path":"http://processx.r-lib.org/dev/news/index.html","id":"processx-383","dir":"Changelog","previous_headings":"","what":"processx 3.8.3","title":"processx 3.8.3","text":"CRAN release: 2023-12-10 *printf() format strings now safer (#379).","code":""},{"path":"http://processx.r-lib.org/dev/news/index.html","id":"processx-382","dir":"Changelog","previous_headings":"","what":"processx 3.8.2","title":"processx 3.8.2","text":"CRAN release: 2023-06-30 client library, used callr, now ignores SIGPIPE writing file descriptor, unix. avoid possible freezes callr::r_session subprocess trying report result main process terminated. particular, happened parallel testthat: https://github.com/r-lib/testthat/issues/1819","code":""},{"path":"http://processx.r-lib.org/dev/news/index.html","id":"processx-381","dir":"Changelog","previous_headings":"","what":"processx 3.8.1","title":"processx 3.8.1","text":"CRAN release: 2023-04-18 Unixes, R processes created callr now feature SIGTERM cleanup handler cleans temporary directory shutting . enable , set PROCESSX_R_SIGTERM_CLEANUP envvar non-empty value.","code":""},{"path":"http://processx.r-lib.org/dev/news/index.html","id":"processx-380","dir":"Changelog","previous_headings":"","what":"processx 3.8.0","title":"processx 3.8.0","text":"CRAN release: 2022-10-26 processx error stacks better now. ANSI hyperlinks function calls manual pages, also print operators better. processx now mark standard streams close--exec Unix, causes problems calling system() R subprocess (https://github.com/r-lib/callr/issues/236).","code":""},{"path":"http://processx.r-lib.org/dev/news/index.html","id":"processx-370","dir":"Changelog","previous_headings":"","what":"processx 3.7.0","title":"processx 3.7.0","text":"CRAN release: 2022-07-07 New functions creating portable FIFOs Unix socket connections. See conn_create_fifo(), conn_create_unix_socket() vignettes/internals.Rmd documentation. functions currently experimental.","code":""},{"path":"http://processx.r-lib.org/dev/news/index.html","id":"processx-361","dir":"Changelog","previous_headings":"","what":"processx 3.6.1","title":"processx 3.6.1","text":"CRAN release: 2022-06-17 processx now closes file unneeded file descriptors redirecting standard output error, client file. processx errors now rlang_error rlang_trace classes, actually compatible rlang errors traces.","code":""},{"path":"http://processx.r-lib.org/dev/news/index.html","id":"processx-360","dir":"Changelog","previous_headings":"","what":"processx 3.6.0","title":"processx 3.6.0","text":"CRAN release: 2022-06-10 processx now gives better error messages, better stack traces.","code":""},{"path":"http://processx.r-lib.org/dev/news/index.html","id":"processx-353","dir":"Changelog","previous_headings":"","what":"processx 3.5.3","title":"processx 3.5.3","text":"CRAN release: 2022-03-25 run() now sets stderr NULL result (instead empty string), standard error redirected standard output. also fixes error interrupting run() redirected standard error. processx now fail current working directory contains non-ASCII character Windows, getwd() returns short path (#313).","code":""},{"path":"http://processx.r-lib.org/dev/news/index.html","id":"processx-352","dir":"Changelog","previous_headings":"","what":"processx 3.5.2","title":"processx 3.5.2","text":"CRAN release: 2021-04-30 run() now truncate stdout stderr output contains multibyte characters (#298, @infotroph). processx now compiles custom compilers enable OpenMP (#297). processx now avoids race condition working directory changed right starting process, potentially sub-process initialized (#300). processx now works non-ASCII path names non-UTF-8 Unix platforms (#293).","code":""},{"path":"http://processx.r-lib.org/dev/news/index.html","id":"processx-351","dir":"Changelog","previous_headings":"","what":"processx 3.5.1","title":"processx 3.5.1","text":"CRAN release: 2021-04-04 Fix potential failure polling curl file descriptors Windows.","code":""},{"path":"http://processx.r-lib.org/dev/news/index.html","id":"processx-350","dir":"Changelog","previous_headings":"","what":"processx 3.5.0","title":"processx 3.5.0","text":"CRAN release: 2021-03-23 can now append environment variables ones set current process include \"current\" value env, run() process$new(): env = c(\"current\", NEW = \"newvalue\") (#232). Sub-processes can now inherit standard input, output error main R process, setting corresponding argument empty string. E.g. run(\"ls\", stdout = \"\") (#72). run() now much faster large standard output standard error (#286). run() can now discard standard output error redirect file(s), instead collecting . processx now optionally uses cli package color error messages stack traces, instead crayon.","code":""},{"path":"http://processx.r-lib.org/dev/news/index.html","id":"processx-345","dir":"Changelog","previous_headings":"","what":"processx 3.4.5","title":"processx 3.4.5","text":"CRAN release: 2020-11-30 New options pty_options set initial size pseudo terminal. Reading standard output error now crash occasionally \\n character beginning input buffer (#281).","code":""},{"path":"http://processx.r-lib.org/dev/news/index.html","id":"processx-344","dir":"Changelog","previous_headings":"","what":"processx 3.4.4","title":"processx 3.4.4","text":"CRAN release: 2020-09-03 processx now works correctly non-ASCII commands arguments passed native encoding, Windows (#261, #262, #263, #264). Providing multiple environment variables now works windows (#267).","code":""},{"path":"http://processx.r-lib.org/dev/news/index.html","id":"processx-343","dir":"Changelog","previous_headings":"","what":"processx 3.4.3","title":"processx 3.4.3","text":"CRAN release: 2020-07-05 supervisor (activated supervise = TRUE) crash Windows Subsystem Linux (WSL) now (#222). Fix ABI compatibility pre post R 4.0.1 versions. Now CRAN builds (R 4.0.2 later 4.0.x) work well R 4.0.0. Now processx can run commands UNC paths specified forward slashes: //hostname/... UNC paths usual back-slashes always fine (#249). $as_ps_handle() method works now better; previously sometimes created invalid ps::ps_handle object, system clock changed (#258).","code":""},{"path":"http://processx.r-lib.org/dev/news/index.html","id":"processx-342","dir":"Changelog","previous_headings":"","what":"processx 3.4.2","title":"processx 3.4.2","text":"CRAN release: 2020-02-09 run() now better job displaying spinner terminals buffer output (#223). Error messages now fully printed error. non-interactive sessions, stack trace printed well. improved error messages. Errors C code now include name C function, errors belong process include system command (#197). processx crash now process receives SIGPIPE signal trying write pipe, end already exited. processx now works better fork clusters parallel package. See ‘Mixing processx parallel base R package’ README file (#236). processx now block SIGCHLD default subprocess, blocking potentially causes zombie sub-subprocesses (#240). process$wait() method now leak file descriptors Unix interrupted (#141).","code":""},{"path":"http://processx.r-lib.org/dev/news/index.html","id":"processx-341","dir":"Changelog","previous_headings":"","what":"processx 3.4.1","title":"processx 3.4.1","text":"CRAN release: 2019-07-18 Now run() create ok variable global environment.","code":""},{"path":"http://processx.r-lib.org/dev/news/index.html","id":"processx-340","dir":"Changelog","previous_headings":"","what":"processx 3.4.0","title":"processx 3.4.0","text":"CRAN release: 2019-07-03 Processx now better error messages, particular, errors C code contain file name line number, system error code message (applicable). Processx now sets .Last.error variable every un-caught processx error error condition, also sets .Last.error.trace stack trace. run() now prints last 10 lines standard error stream error, echo = FALSE, also prints exit status process. run() now includes standard error condition signalled interrupt. process now supports creating pseudo terminals Unix systems. conn_create_pipepair() gets new argument set pipes blocking non-blocking. process set inherited extra connections blocking, also close starting subprocess. now responsibility user. Note breaking change. run() now passes extra ... arguments process$new(). run() now error process killed callback.","code":""},{"path":"http://processx.r-lib.org/dev/news/index.html","id":"processx-331","dir":"Changelog","previous_headings":"","what":"processx 3.3.1","title":"processx 3.3.1","text":"CRAN release: 2019-05-08 Fix crash Windows, connection pending read internally finalized.","code":""},{"path":"http://processx.r-lib.org/dev/news/index.html","id":"processx-330","dir":"Changelog","previous_headings":"","what":"processx 3.3.0","title":"processx 3.3.0","text":"CRAN release: 2019-03-10 process can now redirect standard error standard output, via specifying stderr = \"2>&1\". works files pipes. run() can now redirect standard error standard output, via new stderr_to_stdout argument. $kill() $kill_tree() methods get close_connection = TRUE argument closes pipe connections process. run() now always kills process (process tree cleanup_tree TRUE) exiting. also closes pipe connections (#149).","code":""},{"path":"http://processx.r-lib.org/dev/news/index.html","id":"processx-321","dir":"Changelog","previous_headings":"","what":"processx 3.2.1","title":"processx 3.2.1","text":"CRAN release: 2018-12-05 processx depend assertthat now, crayon package now optional dependency.","code":""},{"path":"http://processx.r-lib.org/dev/news/index.html","id":"processx-320","dir":"Changelog","previous_headings":"","what":"processx 3.2.0","title":"processx 3.2.0","text":"CRAN release: 2018-08-16 New process$kill_tree() method, new cleanup_tree arguments run() process$new(), clean process tree rooted processx process. (#139, #143). New process$interupt() method send interrupt process, SIGINT Unix, CTRL+C Windows (#127). New stdin argument process$new() support writing standard input process (#27, #114). New connections argument process$new() support passing extra connections child process, addition standard streams. New poll_connection argument process$new(), extra connection can used poll process, even stdout stderr pipes (#125). poll() now works connections objects, can mixed process objects (#121). New env argument run() process$new(), set environment child process, optionally (#117, #118). Removed $restart() method, less useful expected, hard maintain (#116). New conn_set_stdout() conn_set_stderr() set standard output error calling process. New conn_disable_inheritance() disable stdio inheritance. suggested child processes call immediately starting, file handles inherited . Fixed signal handler bug Unix marked process finished, even (d221aa1f). Fixed bug occasionally caused crashes wait(), Unix (#138). run() interrupted, error message printed, just like interruption R code general. thrown condition now also interrupt class (#148).","code":""},{"path":"http://processx.r-lib.org/dev/news/index.html","id":"processx-310","dir":"Changelog","previous_headings":"","what":"processx 3.1.0","title":"processx 3.1.0","text":"CRAN release: 2018-05-15 Fix interference parallel package, packages redefine SIGCHLD signal handler Unix. processx signal handler overwritten, might miss exit status processes (set NA). run() process$new() allow specifying working directory process (#63). Make debugme package optional dependency (#74). processx now compatible R 3.1.x. Allow polling 64 connections Windows, using IOCP instead WaitForMultipleObjects() (#81, #106). Fix race condition Windows, creating named pipes stdout stderr. client sometimes didn’t wait server, processx failed ERROR_PIPE_BUSY (231, pipe instances busy).","code":""},{"path":"http://processx.r-lib.org/dev/news/index.html","id":"processx-303","dir":"Changelog","previous_headings":"","what":"processx 3.0.3","title":"processx 3.0.3","text":"CRAN release: 2018-05-07 Fix crash windows trying run non-existing command (#90) Fix race condition process$restart() run() process$new() support commandline argument , process cleanup error prone intermediate shell. (#88) processx process objects longer use R connection objects, R connection API retroactive made private R-core processx uses connection class now manage standard output error process. encoding standard output error can specified now, processx re-encodes stdout stderr UTF-8. Cloning process objects disables now, likely causes problems (@wch). supervise option kill child process R crashes (@wch). Add get_output_file get_error_file, has_output_connection() has_error_connection() methods (@wch). stdout stderr default NULL now, .e. discarded (@wch). Fix undefined behavior stdout/stderr read process already finalized, Unix. run(): Better message interruption, kill process interrupted. Unix: better kill count unloading package. Unix: make wait() work SIGCHLD delivered reason. Unix: close inherited file descriptors conservatively. Fix race condition several memory leaks Windows. Fixes running job control allow breaking away job, Windows.","code":""},{"path":"http://processx.r-lib.org/dev/news/index.html","id":"processx-2001","dir":"Changelog","previous_headings":"","what":"processx 2.0.0.1","title":"processx 2.0.0.1","text":"CRAN release: 2017-07-30 unofficial release, created CRAN, fix compilation Solaris.","code":""},{"path":"http://processx.r-lib.org/dev/news/index.html","id":"processx-200","dir":"Changelog","previous_headings":"","what":"processx 2.0.0","title":"processx 2.0.0","text":"CRAN release: 2017-05-30 First public release.","code":""}]