2009-06-02 08:28:23 +02:00
|
|
|
#!/bin/sh
|
|
|
|
|
# Test the --pid option of tail.
|
|
|
|
|
|
2026-01-01 10:56:16 -08:00
|
|
|
# Copyright (C) 2003-2026 Free Software Foundation, Inc.
|
2009-06-02 08:28:23 +02:00
|
|
|
|
|
|
|
|
# This program is free software: you can redistribute it and/or modify
|
|
|
|
|
# it under the terms of the GNU General Public License as published by
|
|
|
|
|
# the Free Software Foundation, either version 3 of the License, or
|
|
|
|
|
# (at your option) any later version.
|
|
|
|
|
|
|
|
|
|
# This program is distributed in the hope that it will be useful,
|
|
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
# GNU General Public License for more details.
|
|
|
|
|
|
|
|
|
|
# You should have received a copy of the GNU General Public License
|
2017-09-19 01:13:23 -07:00
|
|
|
# along with this program. If not, see <https://www.gnu.org/licenses/>.
|
2009-06-02 08:28:23 +02:00
|
|
|
|
2012-09-02 21:55:12 +02:00
|
|
|
. "${srcdir=.}/tests/init.sh"; path_prepend_ ./src
|
2010-11-17 21:35:31 +01:00
|
|
|
print_ver_ tail
|
2009-09-04 21:41:30 +01:00
|
|
|
getlimits_
|
2009-06-02 08:28:23 +02:00
|
|
|
|
2011-08-04 20:52:31 +02:00
|
|
|
touch empty here || framework_failure_
|
2009-06-02 08:28:23 +02:00
|
|
|
|
2015-05-01 05:26:38 +01:00
|
|
|
# Terminate any background tail process
|
|
|
|
|
cleanup_() { kill $pid 2>/dev/null && wait $pid; }
|
2009-06-02 08:28:23 +02:00
|
|
|
|
2015-05-02 10:52:37 +01:00
|
|
|
for mode in '' '---disable-inotify'; do
|
2009-10-01 08:36:25 +01:00
|
|
|
# Use tail itself to create a background process to monitor,
|
|
|
|
|
# which will auto exit when "here" is removed.
|
2015-05-02 10:52:37 +01:00
|
|
|
tail -f $mode here & pid=$!
|
2009-09-04 21:41:30 +01:00
|
|
|
|
|
|
|
|
# Ensure that tail --pid=PID does not exit when PID is alive.
|
2016-11-08 19:57:41 -06:00
|
|
|
returns_ 124 timeout 1 tail -f -s.1 --pid=$pid $mode here || fail=1
|
2009-09-04 21:41:30 +01:00
|
|
|
|
2023-09-18 18:09:29 +02:00
|
|
|
# Ensure that tail --pid=PID does not exit when at least one PID is alive.
|
|
|
|
|
returns_ 124 timeout 1 tail -f -s.1 --pid=$PID_T_MAX --pid=$pid $mode here \
|
|
|
|
|
|| fail=1
|
|
|
|
|
|
2015-05-01 05:26:38 +01:00
|
|
|
cleanup_
|
2009-09-04 21:41:30 +01:00
|
|
|
|
2009-10-01 08:36:25 +01:00
|
|
|
# Ensure that tail --pid=PID exits with success status when PID is dead.
|
2009-09-04 21:41:30 +01:00
|
|
|
# Use an unlikely-to-be-live PID
|
2015-05-02 10:52:37 +01:00
|
|
|
timeout 10 tail -f -s.1 --pid=$PID_T_MAX $mode empty
|
2009-09-04 21:41:30 +01:00
|
|
|
ret=$?
|
2011-06-14 16:22:41 +02:00
|
|
|
test $ret = 124 && skip_ "pid $PID_T_MAX present or tail too slow"
|
2009-09-04 21:41:30 +01:00
|
|
|
test $ret = 0 || fail=1
|
|
|
|
|
|
2009-10-01 08:36:25 +01:00
|
|
|
# Ensure tail doesn't wait for data when PID is dead
|
2016-11-08 19:57:41 -06:00
|
|
|
returns_ 124 timeout 10 tail -f -s10 --pid=$PID_T_MAX $mode empty && fail=1
|
2009-09-04 21:41:30 +01:00
|
|
|
done
|
2009-07-30 15:29:13 +01:00
|
|
|
|
2009-06-02 08:28:23 +02:00
|
|
|
Exit $fail
|