-
Notifications
You must be signed in to change notification settings - Fork 18k
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
runtime: a way to stop creating other threads #10051
Comments
No, there is no way.
Why? |
Go programs are always multi-threaded. unshare(CLONE_NEWUSER) is defined to only work if the program is not multi-threaded. I don't see any way to call it in a Go program. You will have to write a wrapper, perhaps using the /usr/bin/unshare command. See also #1954. |
If you want to use unshare, one way is to call it inside a constructor /* |
@minux thanks for your reply. If no, how to handle argument of the program in this early phase? |
in the constructor, you can't call any Go functions as the Go runtime
hasn't been
initialized yet.
as a workaround, open /proc/self/cmdline and parse the command line
arguments.
|
@minux thanks a lot. |
When I wrote a "hello world" program, only two line:
fmt.Println("xx")
time.Sleep(1000*time.Second)
And then go build, run the program, i found that it will create 2 more threads (3 threads in all).
I wonder if there is a way to stop creating other threads?
Actually, in linux environment, if more threads are created, we can not use unshare(CLONE_NEWUSER) syscall.
The text was updated successfully, but these errors were encountered: