Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 276871
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T00:59:12+00:00 2026-05-12T00:59:12+00:00

I have inherited some code: Process p = new ProcessBuilder(/bin/chmod, 777, path).start(); p.waitFor(); Basically,

  • 0

I have inherited some code:

Process p = new ProcessBuilder("/bin/chmod", "777", path).start();
p.waitFor();

Basically, there is for some ancient and highly voodoo based reason for storing key/value pairs on disk as files. I don’t really want to go into it.

However, I am left with a bunch of IO exceptions:

Exception :Cannot run program "/bin/chmod": java.io.IOException: error=24, Too many open files
Message: Cannot run program "/bin/chmod": java.io.IOException: error=24, Too many open files

And by a bunch I mean in the realms of 10k – millions

I get the feeling the waitFor call was to stop these from occurring waiting for the process to complete it and exit back, however I think the chmod is returning a result before the file is actually closed. Does anyone know if that would be the cause of these exceptions?

My other inclination is that the opening and closing of thousands of files is not happening quickly enough on the java end and that there is something else going on, maybe something like that there is some form of file buffer that isn’t getting cleared out when fw.close() is being called.

I am pretty new to java and this was a hell weird one that has me stumped. (gladly the app still runs somehow.. after spitting out a very large log file that is)

Can anyone else think of a way to get around this, clearing buffers or increasing the files open limit to something where the jvm can keep up with itself (assuming that is the problem)

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-12T00:59:13+00:00Added an answer on May 12, 2026 at 12:59 am

    I presume you are running these chmod commands in a loop – otherwise I don’t see why you’d get so many exceptions. It’s possible that you’re hitting a deadlock because you’re not reading the output of the spawned processes. That certainly used to bite me back in the pre-ProcessBuilder, Runtime.exec() days.

    Change your code snippet to the above pattern:

    try {
        ProcessBuilder pb = new ProcessBuilder("/bin/chmod", "777", path);    
        pb.redirectErrorStream(true); // merge stdout, stderr of process
    
        Process p = pb.start();
        InputStreamReader isr = new  InputStreamReader(p.getInputStream());
        BufferedReader br = new BufferedReader(isr);
    
        String lineRead;
        while ((lineRead = br.readLine()) != null) {
            // swallow the line, or print it out - System.out.println(lineRead);
        }
    
        int rc = p.waitFor();
        // TODO error handling for non-zero rc
    }
    catch (IOException e) {
        e.printStackTrace(); // or log it, or otherwise handle it
    }
    catch (InterruptedException ie) {
        ie.printStackTrace(); // or log it, or otherwise handle it
    } 
    

    (credit: this site) and see if that helps the situation.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 155k
  • Answers 155k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Have a look at the relocate switch of svn worked… May 12, 2026 at 10:38 am
  • Editorial Team
    Editorial Team added an answer I imagine it is buffered in the XmlWriter; try: using(XmlWriter… May 12, 2026 at 10:38 am
  • Editorial Team
    Editorial Team added an answer Take a look at TestComplete, it is a pretty flexible… May 12, 2026 at 10:37 am

Related Questions

I have inherited some code and am getting an error when I try to
string str1 = 12345ABC...\\...ABC100000; // Hypothetically huge string of 100000 + Unicode Chars str1
I have inherited a Java application (servlets) that runs under Tomcat. For historical reasons,
I have inherited a broad, ill-designed web portfolio at my job. Most pages are

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.