diff options
author | Rob Landley <rob@landley.net> | 2019-05-25 19:48:33 -0500 |
---|---|---|
committer | Rob Landley <rob@landley.net> | 2019-05-25 19:48:33 -0500 |
commit | 94777894a95044c5253ec081503085ab9947cfec (patch) | |
tree | d1b706df996629cbde90046b9e841218210388cf /toys/posix | |
parent | c82d3108947c93c9e27553a44f319171776e92a3 (diff) | |
download | toybox-94777894a95044c5253ec081503085ab9947cfec.tar.gz |
Move notify.c into portability.c (collate the #ifdefs), move global variables
into a structure passed as arguments, add x prefix to functions that can fail,
add overflow test.
Diffstat (limited to 'toys/posix')
-rw-r--r-- | toys/posix/tail.c | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/toys/posix/tail.c b/toys/posix/tail.c index 49a7f69b..d49a70c2 100644 --- a/toys/posix/tail.c +++ b/toys/posix/tail.c @@ -36,6 +36,7 @@ GLOBALS( long n, c; int file_no, last_fd; + struct xnotify *not; ) struct line_list { @@ -139,7 +140,7 @@ static void do_tail(int fd, char *name) char *s = name; if (!fd) sprintf(s = toybuf, "/proc/self/fd/%d", fd); - if (notify_add(fd, s) == -1) perror_exit("-f on '%s' failed", s); + if (xnotify_add(TT.not, fd, s)) perror_exit("-f on '%s' failed", s); } if (TT.file_no++) xputc('\n'); @@ -233,13 +234,13 @@ void tail_main(void) } } - if (FLAG(f)) notify_init(toys.optc); + if (FLAG(f)) TT.not = xnotify_init(toys.optc); loopfiles_rw(args, O_RDONLY|WARN_ONLY|(O_CLOEXEC*!FLAG(f)), 0, do_tail); if (FLAG(f) && TT.file_no) { for (;;) { char *path; - int fd = notify_wait(&path), len; + int fd = xnotify_wait(TT.not, &path), len; // Read new data. while ((len = read(fd, toybuf, sizeof(toybuf)))>0) { |