[Toybox] [CLEANUP][watch.c]
haroon maqsood
maqsood3525 at live.com
Wed Aug 22 04:10:51 PDT 2018
Hi Rob,
First of all if my email, format is not right, please let me know as i do not use an email client.
Secondly, i agree with you on the use of popen, this comes from my in experience as to what pending means for a utility.
i thought it was accepted and needed cleanup in the sense of reducing code size.
i wasn't sure why the system() call was used, but i left it as to not redo what the original author had done.
carrying on from the point of knowing what is expected, would you be able to point me towards a something in the pending directory that you have not started on , that i can skim through and perhaps try and cleanup, just to avoid duplicating efforts.
Thanks
Haroon.
________________________________
From: Rob Landley <rob at landley.net>
Sent: Tuesday, August 21, 2018 3:22 PM
To: haroon maqsood; toybox at lists.landley.net
Subject: Re: [Toybox] [CLEANUP][watch.c]
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...
Rob
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.landley.net/pipermail/toybox-landley.net/attachments/20180822/6fb5ff10/attachment.htm>
More information about the Toybox
mailing list