In comments I expressed my concerns about the stability of such a solution because the process might already have been stepped further at the moment the watchdog detects the message in the logfile.
You said to that: The whole thing is about doing an automated analysis for one time on about 50 different inputs. Job done. It is not an academic exercise
.
Ok, for such an use case you can do the following:
# Use stdbuf -oL to make sure the process output
# will get line buffered (instead of default block-buffered)
stdbuf -oL ./process -p param > logfile &
pid=$!
# Again make sure that the output of tail get's
# line buffered. grep -m1 stops after the first
# occurence
stdbuf -oL tail -f logfile | grep -m1 "PATTERN" && kill "${pid}"
Note: I suppose that process
will exit nicely on kill
in this example.