troglobit / finit

Fast init for Linux. Cookies included
https://troglobit.com/projects/finit/
MIT License
621 stars 61 forks source link

Enable support for process substitution #269

Closed wkz closed 2 years ago

wkz commented 2 years ago

Like their more flamboyant brethren, Busybox's ash also supports process substitution. This requires that processes can access an FD as a path in the filesystem, more specifically as /dev/fd/$FD.

The kernel already does all of the heavy lifting for us, by providing /proc/self/fd which holds all the files. We just need Finit to create a /dev/fd -> /proc/self/fd symlink to make use of it.

Talking to @troglobit afk, he suggested that the bootmisc plugin could be a good candidate to handle this.

marcosfrm commented 2 years ago

And also

/dev/stdin -> /proc/self/fd/0
/dev/stdout -> /proc/self/fd/1
/dev/stderr -> /proc/self/fd/2

https://github.com/torvalds/linux/blob/v5.18/Documentation/admin-guide/devices.rst#compulsory-links

udevd used to create these symlinks by default (including /dev/fd -> /proc/self/fd), but it stopped doing so a while back (since v246, https://github.com/systemd/systemd/commit/6b2229c6c60d0486f5eb9ed3088f9c780d7c0233).

troglobit commented 2 years ago

@marcosfrm thank you, I appreciate very much the detailed follow-up! <3