I must run the command "ulimit -n 400" to raise number of allowed open files before I start my program written in C, but is there a way to do the equivalent from within the C program?
That is, increase the number of allowed open file descriptors for that process. (I am not interested in per thread limits.)
Will it involve setting ulimits, then forking a child which will be allowed to have more open files?
Of course, I could write a shell wrapper which runs ulimit, then start my C program, but it feels less elegant. I could also grep through the source code of bash or sh to see how it is done there - maybe I will if I get no answer here.
Also related, if you want to select on a lot of file descriptors, look here.