Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use unshare on Linux when you don't need the full count #9

Open
o11c opened this issue Jun 20, 2022 · 1 comment
Open

Use unshare on Linux when you don't need the full count #9

o11c opened this issue Jun 20, 2022 · 1 comment

Comments

@o11c
Copy link

o11c commented Jun 20, 2022

From the man page unshare(2):

   In addition, CLONE_THREAD, CLONE_SIGHAND, and CLONE_VM can be
   specified in flags if the caller is single threaded (i.e., it is
   not sharing its address space with another process or thread).
   In this case, these flags have no effect.  (Note also that
   specifying CLONE_THREAD automatically implies CLONE_VM, and
   specifying CLONE_VM automatically implies CLONE_SIGHAND.)  If the
   process is multithreaded, then the use of these flags results in
   an error.
@Freaky
Copy link
Collaborator

Freaky commented Jun 20, 2022

This is quite a bit faster than checking /proc (~70x in my test env), but I'm a bit concerned about the long-term stability of this approach:

           ... In particular, as at kernel 3.8, unshare() does not
   implement flags that reverse the effects of CLONE_SIGHAND,
   CLONE_THREAD, or CLONE_VM.  Such functionality may be added in
   the future, if required.

So it'll be fine up until the point at which some smartarse actually implements the functionality the unshare call is asking for...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants