1

I ran:

public class RuntimeExecTest {
public static void main(String[] args) throws IOException {

    Process exec = Runtime.getRuntime().exec(new String[]{"bash", "-c", "ulimit -n"});
    BufferedReader in = new BufferedReader(
            new InputStreamReader(exec.getInputStream()));
    String line = null;
    while ((line = in.readLine()) != null) {
        System.out.println(line);
    }
}

}

on linux as java program. This command returned 50000 which is a number open file descriptors stored in my /etc/security/limits.conf and its a hard limit. But whenever I run:

"bash" "-c" "ulimit -n"

from linux terminal I get 30000 which is my soft limit from /etc/security/limits.conf

Why I get hard limit via java program and soft limit via linux terminal?

I think it's not a problem with wrong command construction. Just java program read wrong values but I don't know why

Michal
  • 109
  • 1
  • 9

0 Answers0