Open HenrikBengtsson opened 2 years ago
Gist:
> con <- rawConnection(raw(), open = "w")
> con
A connection with
description "raw()"
class "rawConnection"
mode "w"
text "binary"
opened "opened"
can read "no"
can write "yes"
> str(con)
'rawConnection' int 5
- attr(*, "conn_id")=<externalptr>
Invalidate above connection:
> con[1] <- -1L
> str(con)
'rawConnection' int -1
- attr(*, "conn_id")=<externalptr>
> con
A connection, specifically, 'rawConnection', but invalid.
For example, if we detect a connection with index K, we can change its index to -1. If the connection is never used, all is fine, and if it's used it'll trigger a run-time error.
The background is that R does not protect against using connections in other R sessions. This should ideally be fixed in R itself, cf. https://github.com/HenrikBengtsson/Wishlist-for-R/issues/81