Reputation: 5069
I have a C program on Ubuntu. This program needs to open a lot of files. So I have to run it as the following:
ulimit -n 10000; ./xyz
Wonder if there is a way to do something within the program xyz itself to increase the limit. The program runs as root user, so it has the necessary privilege. In the C program (source code), I called
system("ulimit -n 10000");
But it doesn't work, which is not surprise.
Upvotes: 0
Views: 51
Reputation: 741
See getrlimit(2)
Consider using the getrlimit(2)
and setrlimit(2)
routines. Note that only a process running with superuser privilege can increase a limit; any user can reduce their resource limits.
Upvotes: 1
Reputation: 494
why not write a wrapper?
xyz_wrapper.sh
ulimit -n 10000; ./xyz
then simply run the wrapper
./xyz_wrapper.sh
Upvotes: 0