aristanetworks / bst

A one-stop shop for process isolation
MIT License
101 stars 9 forks source link

helpers: make sure helpers do not hold extra file descriptors #76

Closed Snaipe closed 1 year ago

Snaipe commented 1 year ago

This solves the same problem as 7fa1d2d (cgroup_helper shan't hold socket for outer_helper process), but goes a bit further by eliminating the entire class of the problem by closing every single file descriptor that isn't actually used by the forked process.

This ensures that long-lived helper processes do not accidentally hold open file descriptors on which parent processes might be waiting for EOF on.

yabberyabber commented 1 year ago

Another alternative is to call dup2 twice

That way you don't need to change the FD's which means it doesn't need to be a macro