inotify-hash-abuse2.sh 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. #!/bin/sh
  2. # Exercise an abort-inducing flaw in inotify-enabled tail -F.
  3. # Like inotify-hash-abuse, but without a hard-coded "9".
  4. # Copyright (C) 2009-2018 Free Software Foundation, Inc.
  5. # This program is free software: you can redistribute it and/or modify
  6. # it under the terms of the GNU General Public License as published by
  7. # the Free Software Foundation, either version 3 of the License, or
  8. # (at your option) any later version.
  9. # This program is distributed in the hope that it will be useful,
  10. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. # GNU General Public License for more details.
  13. # You should have received a copy of the GNU General Public License
  14. # along with this program. If not, see <https://www.gnu.org/licenses/>.
  15. . "${srcdir=.}/tests/init.sh"; path_prepend_ ./src
  16. print_ver_ tail
  17. # Terminate any background tail process
  18. cleanup_() { kill $pid 2>/dev/null && wait $pid; }
  19. # Speedup the non inotify case
  20. fastpoll='-s.1 --max-unchanged-stats=1'
  21. for mode in '' '---disable-inotify'; do
  22. touch f || framework_failure_
  23. tail $mode $fastpoll -F f & pid=$!
  24. for i in $(seq 200); do
  25. kill -0 $pid || break;
  26. mv f g
  27. touch f
  28. done
  29. # Ensure tail hasn't aborted
  30. kill -0 $pid || fail=1
  31. cleanup_
  32. done
  33. Exit $fail