#!/bin/sh
#
# Check whether repeated killing of just forked processes crashes strace.
#
# Copyright (c) 2019-2023 The strace developers.
# All rights reserved.
#
# SPDX-License-Identifier: GPL-2.0-or-later

. "${srcdir=.}/init.sh"

run_prog_skip_if_failed date +%s > /dev/null
s0="$(date +%s)"

run_prog
args="-f -qq -e signal=none -e trace=sched_yield,/kill $args"

# Run strace until the known corner case is observed.
while :; do
	run_strace $args

	# Printing of "<... SYSCALL resumed>" in strace.c:print_event_exit
	# used to segfault when the syscall number had not been obtained
	# on syscall entering.
	grep -q '^[1-9][0-9]* <\.\.\. ??? resumed>) \+= ?$' "$LOG" && exit 0

	s1="$(date +%s)"
	if [ "$((s1-s0))" -gt "$((TIMEOUT_DURATION/2))" ]; then
		skip_ 'Unable to reproduce <... ??? resumed>'
	fi
done
