5

In a groovy script I execute an application on linux and windows with:

def proc = command.execute()
proc.consumeProcessOutput( System.out, System.err)
    println "here"
proc.waitFor()
    println "never here"

but the waitFor() call never returns. The strange thing is that it only happens on linux.

Based on this: process.waitFor() never returns

it could be caused by not reading from the appropriate streams. But as you can see I consume both System.out, System.err. Are there other streams that could be consumed?

Community
  • 1
  • 1
u123
  • 15,603
  • 58
  • 186
  • 303

1 Answers1

1

I also had similar problem and the process being run was only hanging on jenkins CI server. It was a plutil command and consumeProcessOutputStream method was used.

Since there I use ProcessBuilder to construct and run processes.

def processBuilder = new ProcessBuilder('some command')
processBuilder.directory(new File('some dir')).environment().putAll([:])
processBuilder.redirectOutput(new File('out'))
processBuilder.redirectError(new File('err'))

Unfortunately no idea what causes Your problem.

Opal
  • 81,889
  • 28
  • 189
  • 210