Rethink how we give file descriptors / handles to child processes
Categories
(Core :: IPC, enhancement, P3)
Tracking
()
Tracking | Status | |
---|---|---|
firefox60 | --- | affected |
People
(Reporter: jld, Unassigned)
References
Details
(Whiteboard: [overhead:noted])
Comment 1•7 years ago
|
||
Updated•7 years ago
|
Comment 2•6 years ago
|
||
Reporter | ||
Comment 3•6 years ago
|
||
Reporter | ||
Comment 4•6 years ago
|
||
Updated•6 years ago
|
Reporter | ||
Updated•6 years ago
|
Reporter | ||
Comment 5•4 years ago
|
||
Here's an idea: assuming a centralized list of all possible handles needed at startup, then on both Windows and Unix we could just pass one command-line flag, -fdMap
or something, with a comma-separated list of the fd/handle values in decimal, in the order that they're listed in the big enum.
Both platforms have in-band nulls (-1
on Unix, 0
a.k.a. NULL
on Windows) usable to represent handles that aren't passed; any that aren't meaningful on the platform / build type in question (e.g., IPC on Windows) could even be handled this way instead of trying to ifdef them. UniqueFileHandle
should be useful here; both GeckoChildProcessHost
and whatever global singleton is created in the child process can have an array of them, behind a suitable abstraction.
For Unix, the fds could be 3+n
as currently, or use the same values as the parent (just clearing close-on-exec instead of using dup2
, similar to Windows handle inheritance), or even be randomized; it won't really matter, although a nondeterministic option would detect accidental hard-coding.
Some of these are for shared memory, so we'll also want to allow adding a length (maybe with syntax like <fd-or-handle>:<length>
) and converting to/from base::SharedMemory
; this is already being done with the existing collection of ad-hoc solutions.
Android is its own thing, but fundamentally we just need to get an array of optional fds (and optional lengths) to/from Java, message it to the child as we're currently doing with the existing collection of fds, and then it can proceed like normal Unix.
Updated•2 years ago
|
Description
•