A user attempted to set ulimit -n from within a Go program to restrict it within the program rather than globally, using the setrlimit and getrlimit system calls. However, an error occurred when trying to set the value, stating "invalid argument."
It was discovered that the issue was due to Go bugs in Getrlimit and Setrlimit for Linux 32-bit distributions. These bugs have since been fixed, and the following steps can be taken to resolve the problem:
After updating to the Go default branch tip and rebuilding the program, the expected behavior is observed:
$ ./rlimit {1024 4096} Error Setting Rlimit operation not permitted Rlimit Final {1024 4096} $ sudo ./rlimit [sudo] password for peterSO: {1024 4096} Rlimit Final {999999 999999}
Note: For Linux/amd64 distributions, the issue was not encountered. The problem was specific to Linux 32-bit distributions.
Disclaimer: All resources provided are partly from the Internet. If there is any infringement of your copyright or other rights and interests, please explain the detailed reasons and provide proof of copyright or rights and interests and then send it to the email: [email protected] We will handle it for you as soon as possible.
Copyright© 2022 湘ICP备2022001581号-3