rob at landley.net
Tue Aug 21 08:22:36 PDT 2018
On 08/20/2018 03:13 AM, haroon maqsood wrote:
> Hi Rob,
> Thanks a lot for the feedback,
> Noted, i will be more careful next time .
It's a hard problem to get right. (Well, by my standards anyway.)
If you do "watch -n 2 sleep 5" on debian you get no output for 5 seconds, and
then it updates every 7 seconds instead of every 5. Also if you do:
watch 'while true; do sleep .1; echo -n .; done'
On debian you get no output ever (it's waiting to read a line).
Watch should use popen() instead of system(), use poll() as the timeout
mechanism, read() the output as it becomes available fit it to the screen. It
should use the ascii probe logic as part of its screen size probing, which means
it needs the scan_key logic in lib/ to parse the result. (Poll can check both.
And as long as we're doing that "q" should quit too, so it's unkillable when run
without job control.) At timeout it should kill the old process with a signal if
it hasn't exited net (we need a SIGCHLD handler because you can't poll() and
wait4() at the same time), and if the old pid hasn't exited by a SECOND timeout
kill -9 it. Whether or not these count against -e and -b is a design todo item.
This is a largeish redesign of the loop. Working on it...
More information about the Toybox