plugin_exec

exec plugin

This plugin executes an external command and returns the output from stdout.


exec(command, interval)run external command

This plugin returns the output of any external command.

Fine. But what the f*ck is this 'interval' parameter for?

Okay, you asked for it. Your fault.

LCD4Linux is quite timing-crtitical: All the widgets have their own update interval, and some displays have a narrow timing anyway. Now external commands tend to take longer as you'd expect them to. So the timing may get dazed and confused.

So I implemented threads (forking) for external commands. Every exec function forks off as a separate thread, calling the external command every interval msec, and stores the result. The main LCD4Linux process collects this data with the use of shared memory. This data collection is very fast, and doesn't disturb the internal timings. If the external command hasn't finished yet, the old copy from the previous run is used.

This is ugly, I know. Feel free to provide a better solution :-)

The exec plugin should be considered a last resort. It may be much more intelligent to write a specific plugin for the task.

Further, when running lcd4linux with -F, quitting with control-C does not kill the forked children, at least not in the case where the forked chilren fail to exec their command


exec('head -1 /etc/passwd', 1000)

  • plugin_exec.txt
  • Last modified: 2020/07/17 18:33
  • (external edit)