]> git.ipfire.org Git - thirdparty/coreutils.git/commitdiff
tail: properly parse fractional seconds when monitoring a pid
authorPádraig Brady <P@draigBrady.com>
Thu, 30 Jul 2009 14:29:13 +0000 (15:29 +0100)
committerJim Meyering <meyering@redhat.com>
Thu, 30 Jul 2009 15:40:43 +0000 (17:40 +0200)
* src/tail.c (tail_forever_inotify): The fractional
part of the delay was 1000 times too large.
* tests/tail-2/pid: Add a test to ensure the
timeout happens for this case.

src/tail.c
tests/tail-2/pid

index 5efaf57d98430e2f9a86f345f6b181ac53f72171..8aa31d5575ad2ad0f02bc67346c86075403191b6 100644 (file)
@@ -1268,7 +1268,7 @@ tail_forever_inotify (int wd, struct File_spec *f, size_t n_files,
           FD_SET (wd, &rfd);
 
           select_timeout.tv_sec = (time_t) sleep_interval;
-          select_timeout.tv_usec = 1000000000 * (sleep_interval
+          select_timeout.tv_usec = 1000000 * (sleep_interval
                                                  - select_timeout.tv_sec);
 
           n_descriptors = select (wd + 1, &rfd, NULL, NULL, &select_timeout);
index 446c6dbe38557ead27f99399513dab755b980188..b290f012c3f601cfc999361972ee1c660a0e2e7b 100755 (executable)
@@ -70,4 +70,8 @@ fi
 getlimits_
 tail --pid=$INT_MAX -f /dev/null || fail=1
 
+# Ensure fractional sleep parameter is honored with --pid
+timeout 1 tail -s.1 -f /dev/null --pid=$PID_T_MAX
+test $? = 124 && fail=1
+
 Exit $fail