3 ms·
This is a (rare?) instance where I would say Win32 gives you some remedy over POSIX. On Windows, you can open a handle and deal with that, rather than a pid.
by asveikau 5y ago
This is a (rare?) instance where I would say Win32 gives you some remedy over POSIX. On Windows, you can open a handle and deal with that, rather than a pid. Once the handle is open, it isn't subject to this recycling problem.
However if opening a handle based on pid you may want to double-check that the handle matches your expectation before using it, since that would be prone to the same race.
- simcop2387 5y agoThis is actually what pidfd does on linux, you get a handle to the process that lets you interact with it in that same manner. Once the process exits the handle gets closed and all the operations will report an error even if you have a recycled pid
- surajrmal 5y agoNot that it matters much these days, but do note that pidfd is a Linux concept, not a posix one. It's also a fairly recent one and it'll be a number of years before many people can use it even still. Windows by comparison has had a solution for white some time.
- surajrmal 5y agoI dont care much for Windows, but I would argue that it's well architected compared to nix in many regards.