Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Groovy execute process hangs

Tags:

process

groovy

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?

like image 745
u123 Avatar asked Nov 10 '22 08:11

u123


1 Answers

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.

like image 123
Opal Avatar answered Nov 15 '22 05:11

Opal