izocan
izocan

Reputation: 291

Ant execution timeout doesn't terminate task

I am using following ant task:

<target name="task">
    <exec executable="grunt.cmd" dir="adir" failonerror="true" timeout="1000">      
        <arg value="test" />
        <arg value="-v" />
    </exec>     
</target>

I want the ant task to be terminated after one second. But it does not affect any changes. The tasks runs through. After finishing the task, the following message occurs:

Timeout: killed the sub-process

But the timeout is completely ignored.

Any ideas regarding to this problem?

Upvotes: 1

Views: 1001

Answers (1)

Rebse
Rebse

Reputation: 10377

Usually cmd files are executed via <exec executable="cmd">, also try setting spawn attribute, f.e :

<exec executable="cmd" dir="adir" failonerror="true" timeout="1000" spawn="true">
  <arg value="/c"/>
  <arg value="grunt.cmd"/>
  <arg value="test"/>
  <arg value="-v"/>
</exec>

Otherwise ant will wait for the process to complete because it collects stdout/stderr output.
Alternatively use :

<parallel threadcount="1" timeout="1000">
 <exec executable="cmd" dir="adir" failonerror="true">
  <arg value="/c"/>
  <arg value="grunt.cmd"/>
  <arg value="test"/>
  <arg value="-v"/>
 </exec>
</parallel>

Upvotes: 2

Related Questions