diff options
author | Pádraig Brady <P@draigBrady.com> | 2009-09-04 21:41:30 +0100 |
---|---|---|
committer | Pádraig Brady <P@draigBrady.com> | 2009-09-05 17:19:03 +0100 |
commit | 526a057602f7f312443ae4ec0653fec84bca9ff2 (patch) | |
tree | 16532c0aaac442092426ccebd166e02b5ef935d7 /src/tail.c | |
parent | 70eadcb4e6990f0d1c9186ba6fa9f8e747cf3a22 (diff) | |
download | coreutils-526a057602f7f312443ae4ec0653fec84bca9ff2.tar.xz |
tests: test old tail -f method even on systems with inotify
* src/tail.c (main): Add an undocumented ---disable-inotify option
to allow disabling inotify.
* tests/tail-2/pid: Run test in both normal and "disable_inotify" modes.
* tests/tail-2/tail-n0f: Likewise.
* tests/tail-2/wait: Likewise.
* tests/tail-2/append-only: Likewise.
Diffstat (limited to 'src/tail.c')
-rw-r--r-- | src/tail.c | 30 |
1 files changed, 22 insertions, 8 deletions
diff --git a/src/tail.c b/src/tail.c index f0dbf5d5e..6077473c0 100644 --- a/src/tail.c +++ b/src/tail.c @@ -201,6 +201,10 @@ static bool have_read_stdin; more expensive) code unconditionally. Intended solely for testing. */ static bool presume_input_pipe; +/* If nonzero then don't use inotify even if available. + Intended solely for testing. */ +static bool disable_inotify; + /* For long options that have no equivalent short option, use a non-character as a pseudo short option, starting with CHAR_MAX + 1. */ enum @@ -209,7 +213,8 @@ enum MAX_UNCHANGED_STATS_OPTION, PID_OPTION, PRESUME_INPUT_PIPE_OPTION, - LONG_FOLLOW_OPTION + LONG_FOLLOW_OPTION, + DISABLE_INOTIFY_OPTION }; static struct option const long_options[] = @@ -218,6 +223,8 @@ static struct option const long_options[] = {"follow", optional_argument, NULL, LONG_FOLLOW_OPTION}, {"lines", required_argument, NULL, 'n'}, {"max-unchanged-stats", required_argument, NULL, MAX_UNCHANGED_STATS_OPTION}, + {"-disable-inotify", no_argument, NULL, + DISABLE_INOTIFY_OPTION}, /* do not document */ {"pid", required_argument, NULL, PID_OPTION}, {"-presume-input-pipe", no_argument, NULL, PRESUME_INPUT_PIPE_OPTION}, /* do not document */ @@ -1794,6 +1801,10 @@ parse_options (int argc, char **argv, } break; + case DISABLE_INOTIFY_OPTION: + disable_inotify = true; + break; + case PID_OPTION: { strtol_error s_err; @@ -1972,15 +1983,18 @@ main (int argc, char **argv) if (forever) { #if HAVE_INOTIFY - int wd = inotify_init (); - if (wd < 0) - error (0, errno, _("inotify cannot be used, reverting to polling")); - else + if (!disable_inotify) { - tail_forever_inotify (wd, F, n_files, sleep_interval); + int wd = inotify_init (); + if (wd < 0) + error (0, errno, _("inotify cannot be used, reverting to polling")); + else + { + tail_forever_inotify (wd, F, n_files, sleep_interval); - /* The only way the above returns is upon failure. */ - exit (EXIT_FAILURE); + /* The only way the above returns is upon failure. */ + exit (EXIT_FAILURE); + } } #endif tail_forever (F, n_files, sleep_interval); |