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:[27636]                                                
#>  2     1 pipe:[27637]                                                
#>  3     2 pipe:[27638]                                                
#>  4     3 /home/runner/work/_temp/ef40bc6d-106a-4ab3-9dfa-ed0f93308027
#>  5     4 anon_inode:[eventpoll]                                      
#>  6     5 anon_inode:[io_uring]                                       
#>  7     6 anon_inode:[io_uring]                                       
#>  8     7 pipe:[28606]                                                
#>  9     8 pipe:[28606]                                                
#> 10     9 pipe:[28607]                                                
#> 11    10 pipe:[28607]                                                
#> 12    11 anon_inode:[eventfd]                                        
#> 13    12 pipe:[28611]                                                
#> 14    13 pipe:[28611]                                                
#> 15    18 /tmp/RtmpWUfar3/Rf19d9444079a1 (deleted)                    
#> 16   142 pipe:[14814]                                                
#> 17   145 pipe:[14815]                                                
f <- file(tmp <- tempfile(), "w")
ps_open_files(p)
#> # A data frame: 18 × 2
#>       fd path                                                        
#>    <int> <chr>                                                       
#>  1     0 pipe:[27636]                                                
#>  2     1 pipe:[27637]                                                
#>  3     2 pipe:[27638]                                                
#>  4     3 /home/runner/work/_temp/ef40bc6d-106a-4ab3-9dfa-ed0f93308027
#>  5     4 anon_inode:[eventpoll]                                      
#>  6     5 anon_inode:[io_uring]                                       
#>  7     6 anon_inode:[io_uring]                                       
#>  8     7 pipe:[28606]                                                
#>  9     8 pipe:[28606]                                                
#> 10     9 pipe:[28607]                                                
#> 11    10 pipe:[28607]                                                
#> 12    11 anon_inode:[eventfd]                                        
#> 13    12 pipe:[28611]                                                
#> 14    13 pipe:[28611]                                                
#> 15    18 /tmp/RtmpWUfar3/Rf19d9444079a1 (deleted)                    
#> 16    19 /tmp/RtmpWUfar3/file19d9d392c0b                             
#> 17   142 pipe:[14814]                                                
#> 18   145 pipe:[14815]                                                
close(f)
unlink(tmp)
ps_open_files(p)
#> # A data frame: 17 × 2
#>       fd path                                                        
#>    <int> <chr>                                                       
#>  1     0 pipe:[27636]                                                
#>  2     1 pipe:[27637]                                                
#>  3     2 pipe:[27638]                                                
#>  4     3 /home/runner/work/_temp/ef40bc6d-106a-4ab3-9dfa-ed0f93308027
#>  5     4 anon_inode:[eventpoll]                                      
#>  6     5 anon_inode:[io_uring]                                       
#>  7     6 anon_inode:[io_uring]                                       
#>  8     7 pipe:[28606]                                                
#>  9     8 pipe:[28606]                                                
#> 10     9 pipe:[28607]                                                
#> 11    10 pipe:[28607]                                                
#> 12    11 anon_inode:[eventfd]                                        
#> 13    12 pipe:[28611]                                                
#> 14    13 pipe:[28611]                                                
#> 15    18 /tmp/RtmpWUfar3/Rf19d9444079a1 (deleted)                    
#> 16   142 pipe:[14814]                                                
#> 17   145 pipe:[14815]