#1
  1. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2008
    Posts
    32
    Rep Power
    6

    Program hangs when running UNIX commands


    I call a UNIX command to move or delete files in a UNIX directory. I use the waitFor method. When there is a file permission issue or too many files that meet the delete criteria, the program will just hang and the return code is never received. If these scenarios happen, how can I get the program to continue or quit?

    Here's some sample code:

    Process child4 = Runtime.getRuntime().exec(mvfcl_array);
    int retval4=child4.waitFor();
    if (retval4==0){
    System.out.println("FAX FCL was successfully moved to archive.\n");
    } else
    {
    System.out.println("FAX FCL move to archive failed!\n");
    }


    For thr above mentioned errors, the messages never get printed. The return code is not being returned. I'd put a System.exit in the error logic, but since the return code doesn't seem to be returned, that would do nothing
  2. #2
  3. Java Junkie
    Devshed Specialist (4000 - 4499 posts)

    Join Date
    Jan 2004
    Location
    Mobile, Alabama
    Posts
    4,021
    Rep Power
    1285
    Try using ProcessBuilder

IMN logo majestic logo threadwatch logo seochat tools logo