Run Shell event
Run Shell event shall be fired when a shell command prints to its standard output (stdout) a line matching a pattern.
Example:
event Run Shell [ Command: getevent Line:*00000004 Use Root:On ]
The typical usage is to monitor keypresses (via getevent utility) and system log records (via logcat utility).
Note: An implementation should ensure that the line buffering only is performed by an operating system and run time libraries. Any other buffering would make the event meaningless.
Perhaps, a virtual terminal (pty) is the best IPC to be used.
Automagic implements Command Output trigger, see http://automagic4android.com/en/help/components-triggers#trigger_command_output but the triiger may be delayed for a long time due to the full buffering discipline. Thus, a text line may be buffered in an output buffer, in a pipe, or in an input buffer.
Known implementations in Tasker use the Run Shell action with a script like
busybox script getevent | while read line; do <matching $line here> && am broadcast -a net.dinglisch.android.tasker.ACTION_TASK -e task_name TaskerTask; done
The script applet in busybox uses the virtual terminal IPC, so the stdio library sets the line buffering for the standard output of getevent. The read operator in a shell uses the same buffering too for the standard input and eliminates any buffering in the pipe.