0

I am calling Java ProcessBuilder to create a process from an exe file. the processes are created but they can not work ( in this case the work is doing sftp ) and hang after transfering a small number of bytes. they start to work properly after I Kill the java from windows task manager. 1- why the processes with a parent are restricted and does anybody know what are these restrictions? 2- How can I detach these processes from the parent ( Java Virtual Machine) to make them independent from windows point of view?

This is the Java Code calling exe file:

public boolean RunFileClient(client_drive_info drive)
    {

        Process proc = null;

        try {
            System.out.println(currentDir+"\\FileClient.exe "+ drive.getIp()+ " "+drive.getPort()+" "+ clientinfo.getUser_id()+" "+ drive.getDrives_id()+" "+ drive.getDrive_letter()+":\\"+  " "+ this.clientrestartmsg.getFilename());
            ProcessBuilder procb= new ProcessBuilder(currentDir+"\\FileClient.exe",drive.getIp(), ""+drive.getPort(),""+ clientinfo.getUser_id(),
                                            ""+ drive.getDrives_id(),drive.getDrive_letter()+":\\", clientrestartmsg.getFilename() );

         proc=procb.start();

        } catch (IOException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
        drive.setFileClientProc(proc);
        return true;
    }

The FileClient.exe is a windows application which runs without any userinterface commmunication and uses libssh (ssh1) libraries to do SFTP. all the parameters are received correctly by exe program and it works fine when it is called during CreateProcess of Microsoft VC++. it also works fine when transferring small files. and also it works fine if you kill Java Virtual machine! Nothing is read from this program stdout. I could put all source codes but the site limits maximum length.

Desphilboy
  • 962
  • 13
  • 13
  • 2
    I guess that problem is in your code that probably reads from stdout of created process. Please show your code, otherwise it is impossible to recommend you something valuable. – AlexR Sep 04 '14 at 08:02
  • Try reading from both the `stdout` and `stderr` of the process, or merge them. – user207421 Sep 09 '14 at 02:46
  • I dont need any input or output from this process. all Inputs are given as command line params and the only output is a log being generated by the process. I read in the infopage that stdin and stdout will be mapped into the counterparts of parent process. does this prevent a process from running ? – Desphilboy Sep 09 '14 at 03:51
  • the process stops in sftp_write() function after transferring 800 KB of data which is irrelative. I tried running that process using an intermediate exe program and it worked fine. – Desphilboy Sep 09 '14 at 04:00

0 Answers0