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.
The above is the detailed content of Why does setting `ulimit -n` from a Go program on Linux 32-bit distributions result in an \'invalid argument\' error?. For more information, please follow other related articles on the PHP Chinese website!