Workaround a bug introduced in GNU grep 2.27, for details see
https://lists.gnu.org/archive/html/bug-grep/2016-12/msg00011.html
* tests/init.sh (grep_pid_status): New function.
* tests/detach-running.test: Use it instead of grep to search
in /proc/$pid/status.
* tests/detach-sleeping.test: Likewise.
* tests/detach-stopped.test: Likewise.
cleanup
dump_log_and_fail_with 'tracee died after detach'
}
- grep '^State:.*R (running)' < /proc/$tracee_pid/status > /dev/null || {
- grep '^State:' < /proc/$tracee_pid/status
+ grep_pid_status "$tracee_pid" '^State:.*R (running)' > /dev/null || {
+ grep_pid_status "$tracee_pid" '^State:'
cleanup
dump_log_and_fail_with 'tracee is not running after detach'
}
cleanup
dump_log_and_fail_with 'tracee died after detach'
}
- grep '^State:.*S (sleeping)' < /proc/$tracee_pid/status > /dev/null || {
- grep '^State:' < /proc/$tracee_pid/status
+ grep_pid_status "$tracee_pid" '^State:.*S (sleeping)' > /dev/null || {
+ grep_pid_status "$tracee_pid" '^State:'
cleanup
dump_log_and_fail_with 'tracee is not sleeping after detach'
}
cleanup
dump_log_and_fail_with 'tracee died after detach'
}
- grep '^State:.*T (stopped)' < /proc/$tracee_pid/status > /dev/null || {
- grep '^State:' < /proc/$tracee_pid/status
+ grep_pid_status "$tracee_pid" '^State:.*T (stopped)' > /dev/null || {
+ grep_pid_status "$tracee_pid" '^State:'
cleanup
dump_log_and_fail_with 'tracee is not group-stopped after detach'
}
skip_ "the kernel release $uname_r is not $1 or newer"
}
+# Usage: grep_pid_status $pid GREP-OPTIONS...
+grep_pid_status()
+{
+ local pid
+ pid=$1; shift
+ cat < "/proc/$pid/status" | grep "$@"
+}
+
check_prog cat
check_prog rm