Skip to content

Note that in some IDEs, e.g. RStudio or R.app on macOS, the IDE itself opens files from other threads, in addition to the files opened from the main R thread.

Usage

ps_open_files(p = ps_handle())

Arguments

p

Process handle.

Value

Data frame with columns: fd and path. fd is numeric file descriptor on POSIX systems, NA on Windows. path is an absolute path to the file.

Details

For a zombie process it throws a zombie_process error.

Examples

p <- ps_handle()
ps_open_files(p)
#> # A data frame: 17 × 2
#>       fd path                                                        
#>    <int> <chr>                                                       
#>  1     0 pipe:[31093]                                                
#>  2     1 pipe:[31094]                                                
#>  3     2 pipe:[31095]                                                
#>  4     3 /home/runner/work/_temp/1a362674-bafb-44d0-908a-cc673aea222d
#>  5     4 anon_inode:[eventpoll]                                      
#>  6     5 anon_inode:[io_uring]                                       
#>  7     6 anon_inode:[io_uring]                                       
#>  8     7 pipe:[32407]                                                
#>  9     8 pipe:[32407]                                                
#> 10     9 pipe:[32408]                                                
#> 11    10 pipe:[32408]                                                
#> 12    11 anon_inode:[eventfd]                                        
#> 13    12 pipe:[30306]                                                
#> 14    13 pipe:[30306]                                                
#> 15    18 /tmp/Rtmpw3u4Ws/Rf1b795bcc24a9 (deleted)                    
#> 16   142 pipe:[14118]                                                
#> 17   145 pipe:[14119]                                                
f <- file(tmp <- tempfile(), "w")
ps_open_files(p)
#> # A data frame: 18 × 2
#>       fd path                                                        
#>    <int> <chr>                                                       
#>  1     0 pipe:[31093]                                                
#>  2     1 pipe:[31094]                                                
#>  3     2 pipe:[31095]                                                
#>  4     3 /home/runner/work/_temp/1a362674-bafb-44d0-908a-cc673aea222d
#>  5     4 anon_inode:[eventpoll]                                      
#>  6     5 anon_inode:[io_uring]                                       
#>  7     6 anon_inode:[io_uring]                                       
#>  8     7 pipe:[32407]                                                
#>  9     8 pipe:[32407]                                                
#> 10     9 pipe:[32408]                                                
#> 11    10 pipe:[32408]                                                
#> 12    11 anon_inode:[eventfd]                                        
#> 13    12 pipe:[30306]                                                
#> 14    13 pipe:[30306]                                                
#> 15    18 /tmp/Rtmpw3u4Ws/Rf1b795bcc24a9 (deleted)                    
#> 16    19 /tmp/Rtmpw3u4Ws/file1b796b8b650d                            
#> 17   142 pipe:[14118]                                                
#> 18   145 pipe:[14119]                                                
close(f)
unlink(tmp)
ps_open_files(p)
#> # A data frame: 17 × 2
#>       fd path                                                        
#>    <int> <chr>                                                       
#>  1     0 pipe:[31093]                                                
#>  2     1 pipe:[31094]                                                
#>  3     2 pipe:[31095]                                                
#>  4     3 /home/runner/work/_temp/1a362674-bafb-44d0-908a-cc673aea222d
#>  5     4 anon_inode:[eventpoll]                                      
#>  6     5 anon_inode:[io_uring]                                       
#>  7     6 anon_inode:[io_uring]                                       
#>  8     7 pipe:[32407]                                                
#>  9     8 pipe:[32407]                                                
#> 10     9 pipe:[32408]                                                
#> 11    10 pipe:[32408]                                                
#> 12    11 anon_inode:[eventfd]                                        
#> 13    12 pipe:[30306]                                                
#> 14    13 pipe:[30306]                                                
#> 15    18 /tmp/Rtmpw3u4Ws/Rf1b795bcc24a9 (deleted)                    
#> 16   142 pipe:[14118]                                                
#> 17   145 pipe:[14119]