|
|
Subscribe / Log in / New account

Attaching file descriptors to processes with CLONE_FD

Attaching file descriptors to processes with CLONE_FD

Posted Apr 2, 2015 20:43 UTC (Thu) by josh (subscriber, #17465)
In reply to: Attaching file descriptors to processes with CLONE_FD by hmh
Parent article: Attaching file descriptors to processes with CLONE_FD

Total size is the value returned from read(); always read the size of the structure you understand, and then process the size of the structure you get back, which may be smaller.

Additional information to distinguish between structures would depend on the structures. For example, if we added a flag to obtain SIGSTOP/SIGCONT information for children (as you can currenly obtain via SIGCHLD), we'd just return exactly the same clonefd_info structure, with CLD_STOPPED or CLD_CONTINUED in the code field; no need to add types or flags for that.


to post comments

Attaching file descriptors to processes with CLONE_FD

Posted Apr 2, 2015 21:48 UTC (Thu) by dlang (guest, #313) [Link] (1 responses)

using the length as the only version indicator is a clever hack, but it only works well as long as you never end up abandoning/depreciating any data. If you do, you end up having to pad the messages with bogus backwards compatibility data, or some rough approximation of it.

I would have thought that the problem with /proc, specifically with slabinfo data that continues to need to be faked by slab replacements, even when it doesn't actually mean anything, would have shown this to be an "anti-pattern"

yes, including version info wastes a little space from the beginning, but it means that you can actually eliminate fields in the future if you find that you should.

Attaching file descriptors to processes with CLONE_FD

Posted Apr 2, 2015 21:53 UTC (Thu) by josh (subscriber, #17465) [Link]

The length isn't the only version indicator; if we need to change something more fundamental, we can use an explicit flag for that.

And no, we can't ever eliminate a field even with a version number, unless we have backward compatibility code to return old versions to old userspace.


Copyright © 2025, Eklektix, Inc.
Comments and public postings are copyrighted by their creators.
Linux is a registered trademark of Linus Torvalds