2

I have used EXEC task to open matlab in build.xml file. I have added timeout in EXEC task for terminate the task after some time. But problem is that, matlab is open and model is also building in matlab but after timeout the exec task not terminate.

<property name="BuildEngine.calc.matlabApp" value="C:\MATLAB\R2010bSP2\bin\matlab.exe"/>
<property name="modelProjectDirectory" value="${basedir}\..\${Config.ModelProject}"/>

<exec executable="${BuildEngine.calc.matlabApp}" dir="${modelProjectDirectory}" timeout="60000">
    <arg value="-r"/>
    <arg value="OutputResolvedParameters"/>
</exec>

after 1 min EXEC task not terminate and matlab still running.

sach28
  • 21
  • 1

1 Answers1

1

One thing is sure: you cannot yet set up a timout on an RTC build: the Enhancement 106064 (you need a jazz account to see it) is "triaged".

Regarding the ant exec task, try adding a spawn=true attribute:

If you run Ant as a background process (like ant &) and use the <exec> task with spawn set to false, you must provide explicit input to the forked process or Ant will be suspended because it tries to read from the standard input.

VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • hi VonC thanks for your update. i have added spawn=true attribute in my exec task. but EXEC terminate and other task also terminate an build failed with error messages. below is the error – sach28 Aug 27 '12 at 08:47
  • build_CUSW: [copy] Copying 1 file to C:\IBM_RTC3\punds_ECS_11458_CUSW_WS_Build_01\FxpECU_TR4_Dev [copy] Copying 1 file to C:\IBM_RTC3\punds_ECS_11458_CUSW_WS_Build_01\FxpECU_TR4_Dev [exec] [exec] C:\IBM_RTC3\punds_ECS_11458_CUSW_WS_Build_01\CC_Build>tskill MATLAB [exec] Could not find process: matlab [exec] Result: 1 spawn does not allow attributes related to input, output, error, result spawn also does not allow timeout finally, spawn is not compatible with a nested I/O BUILD FAILED – sach28 Aug 27 '12 at 08:48
  • @sach28 that is to be expected: the timeout worked, but RTC was monitorng that process and doesn't find it anymore. I was answering the ant part of your question (especially since you deleted the tag rtc) – VonC Aug 27 '12 at 08:52
  • i need to timeout perticulat exec task for paraticular time. it wait for that time nad automatically terminate the task and give error message after build failure. – sach28 Aug 27 '12 at 09:04
  • i have checked with other application with EXEC timeout. it secussefully terminate after timeout. but problem is with matlab application it not terminate after timeout and it still running matlab process. – sach28 Aug 27 '12 at 09:06
  • @sach28 then it is best to wrap your ant script in another (bash or cmd) in order to launch the ant task from that new script (ant task with "`exec spaw=true`"): That way, RTC won't see directly the ant task, and won't mind if it disappears. And your wrapper script will be able to kill the matlab process if it is sill running. – VonC Aug 27 '12 at 09:10
  • yes it kill the matlab process but in RTC, build is still running. we need to abanodend the build. is it possible to abandoned build using ant? – sach28 Aug 27 '12 at 09:18
  • @sach28 again, a wrapper would terminate cleanly after the timeout of the ant it wraps. The RTC launching the wrapper would, in turn, terminates as well. – VonC Aug 27 '12 at 09:32
  • can you please tell me how can i wrapper script? can you please send me example for refer? – sach28 Aug 27 '12 at 09:36
  • please send me wrapper example for reference so i can modified my script as per need. – sach28 Aug 27 '12 at 09:38
  • @sach28 I don't have an example ready: it is just a matter of calling the ant script through a another script instead of referencing the same ant script directly in the RTC build. A bit like http://stackoverflow.com/questions/4256958/command-line-to-run-the-ant-task-with-hyphen-in-the-task-name ; your wrapper would set the `PATH` (to call "`ant`"), and call `ant`. – VonC Aug 27 '12 at 09:47
  • ok thanks i will try this. do you have any other solution for this issue? why timeout not works for matlab application? – sach28 Aug 27 '12 at 10:14
  • i have called new script through a another script with exec spawn= true. but it gives same error as we got first time. do you have any solution for timeout matlab ? – sach28 Aug 27 '12 at 10:47
  • @sach28 no other solution: the idea is for the wrapper to take care of the matlab process, in order to avoid exposing said process to the RTC build. – VonC Aug 27 '12 at 11:06