[Toybox] [PATCH] Better tail -f error checking.

enh enh at google.com
Sat Jan 9 12:57:11 PST 2016


rebased:


Exit immediately if we don't actually have anything to -f --- it's -f's
big brother -F that retries by name rather than by fd.
---
 toys/posix/tail.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/toys/posix/tail.c b/toys/posix/tail.c
index a00bfa0..d1c6250 100644
--- a/toys/posix/tail.c
+++ b/toys/posix/tail.c
@@ -245,7 +245,7 @@ void tail_main(void)
   loopfiles_rw(args, O_RDONLY|(O_CLOEXEC*!(toys.optflags&FLAG_f)),
     0, 0, do_tail);

-  if (toys.optflags & FLAG_f) {
+  if ((toys.optflags & FLAG_f) && TT.file_no) {
     int len, last_fd = TT.files[(TT.file_no-1)*2], i, fd;
     struct inotify_event ev;

-- 
2.6.0.rc2.230.g3dd15c0

On Mon, Dec 21, 2015 at 1:24 PM, enh <enh at google.com> wrote:
> Check for fatal errors, and exit immediately if we don't actually have
> anything to -f --- something like "tail -f /does/not/exist" should exit:
> it's -f's big brother -F that retries by name rather than by fd.
> ---
>  toys/posix/tail.c | 14 +++++---------
>  1 file changed, 5 insertions(+), 9 deletions(-)
>
>
> --
> Elliott Hughes - http://who/enh - http://jessies.org/~enh/
> Android native code/tools questions? Mail me/drop by/add me as a reviewer.



-- 
Elliott Hughes - http://who/enh - http://jessies.org/~enh/
Android native code/tools questions? Mail me/drop by/add me as a reviewer.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-Fix-tail-f-does-not-exist.patch
Type: text/x-patch
Size: 859 bytes
Desc: not available
URL: <http://lists.landley.net/pipermail/toybox-landley.net/attachments/20160109/c6c83132/attachment.bin>


More information about the Toybox mailing list