Exec binding executes script with errors (forcibly terminating the process)

HI All!

OH3, Exec binging 3.1.0, Raspberry Pi4, Buster.
Set up Exec binding to run external shell script on Item change.
Script gets executed, but OH says “process hasn’t exited - forcibly terminating process” in openhab.log
What is wrong here? Could anyone point me to right direction.

Thing declaration:

Thing exec:command:camera_lux_control [ command="/home/pi/scripts/camera/lux-control.sh %2$s", interval=0, timeout=0, autorun=false ]


rule "Lightsensor changed - run uvcdynctl corrector script"
    Item kitchen_lightsensor_lux changed
   if (kitchen_lightsensor_lux.state < 200) {
       var lux = kitchen_lightsensor_lux.state.toString
       if (camera_lux_control_run.state != ON) {
       else {
            logInfo("camera_lux_control_run", "Script already in use, skipping execution.")


Switch  camera_lux_control_run  {channel="exec:command:camera_lux_control:run", autoupdate="false"}
String  camera_lux_control_args {channel="exec:command:camera_lux_control:input"}
String  camera_lux_control_out  {channel="exec:command:camera_lux_control:output"}

Shell script is runnable by openhab. Moreover, script can be empty: it is empty at this moment - I commented out everything that could cause trouble (trying to catch problem inside the script). It is only:

exit 0

It executes fine:

┌─[pi@pi162] - [~/scripts/camera] - [Вс ноя 14, 20:38]
└─[$] <git:(master*)> ls -al lux-control.sh
-rwxr-xr-x 1 pi openhab 1766 ноя 14 17:45 lux-control.sh
┌─[pi@pi162] - [~/scripts/camera] - [Вс ноя 14, 20:38]
└─[$] <git:(master*)> sudo -u openhab ./lux-control.sh
┌─[pi@pi162] - [~/scripts/camera] - [Вс ноя 14, 20:39]
└─[$] <git:(master*)> echo $?

When script contains code, the code executes normally - logs from script are written, parameters are set - all is fine - no matter if it is run manually or by exec binding.

But every time it executes from OH Exec binding, OH generates errors. Sometimes one warning:

2021-11-14 20:05:27.517 [WARN ] [ng.exec.internal.handler.ExecHandler] - Forcibly termininating the process ('/home/pi/scripts/camera/lux-control.sh 3') after a timeout of 0 ms

Sometimes couple:

2021-11-14 20:12:40.574 [WARN ] [ng.exec.internal.handler.ExecHandler] - Forcibly termininating the process ('/home/pi/scripts/camera/lux-control.sh 2') after a timeout of 0 ms
2021-11-14 20:12:40.579 [WARN ] [mmon.WrappedScheduledExecutorService] - Scheduled runnable ended with an exception:
java.lang.IllegalThreadStateException: process hasn't exited
    at java.lang.ProcessImpl.exitValue(ProcessImpl.java:521) ~[?:?]
    at org.openhab.binding.exec.internal.handler.ExecHandler.execute(ExecHandler.java:286) ~[?:?]
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515) ~[?:?]
    at java.util.concurrent.FutureTask.run(FutureTask.java:264) ~[?:?]
    at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:304) ~[?:?]
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128) [?:?]
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628) [?:?]
    at java.lang.Thread.run(Thread.java:829) [?:?]

You might want to allow a little more time for your script to execute.

Maybe the more complex error report comes from aborting it before it has even started.

OMG, silly me. Of course.
Thank you very much, Rossko.
timeout=2 solved the problem

1 Like

This topic was automatically closed 41 days after the last reply. New replies are no longer allowed.