eclipse-archived / smarthome

Eclipse SmartHome™ project
https://www.eclipse.org/smarthome/
Eclipse Public License 2.0
862 stars 787 forks source link

[ExecUtil] executeCommandLine blocks thread if process don't exit properly #6866

Closed pacive closed 4 years ago

pacive commented 5 years ago

If a badly written script don't exit when signaled, execteCommandLine calls never return, and blocks the execution thread indefinately.

Steps to reproduce: Create a python script (test.py) that ignores signals

import time

while True:
   try:
      time.sleep(10)
   except BaseException:
      None

Execute the script in a rule:

rule "test"
when
   Item Test received command
then
  var result = executeCommandLine("python@@/path/to/script/test.py", 5000)
  logInfo("test.rules", result.toString())
end

executeCommandLine will never return and the thread becomes blocked, possibly preventing other rules to run if the threadpool is full.

More details: https://community.openhab.org/t/solved-executecommandline-sometimes-not-returning-and-blocking-rule-thread/63467/9