I think ideally we could represent file descriptors as an anyref once we have reference-types. For the preopened file descriptors we could designate an anyref table which would be exported to load the references into. fd_renumber could be deprecated and table.set/get could be used instead.
Using a table might also affect how preopened fd's are inherited by forking. Instead of forking there it might be nice to have a something that is tied more closely to wasm like module.instantiate -> modRef The parent processes then could populate the preopened file descriptors table before calling the entry point function.
I think ideally we could represent file descriptors as an
anyrefonce we have reference-types. For the preopened file descriptors we could designate ananyreftable which would be exported to load the references into.fd_renumbercould be deprecated andtable.set/getcould be used instead.Using a table might also affect how preopened fd's are inherited by forking. Instead of forking there it might be nice to have a something that is tied more closely to wasm like
module.instantiate -> modRefThe parent processes then could populate the preopened file descriptors table before calling the entry point function.