#!/bin/sh
#
# Check that simultaneous use of -p option and tracing of a command works.
#
# Copyright (c) 2016 Dmitry V. Levin <ldv@strace.io>
# Copyright (c) 2016-2021 The strace developers.
# All rights reserved.
#
# SPDX-License-Identifier: GPL-2.0-or-later

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

run_prog_skip_if_failed \
	kill -0 $$

../set_ptracer_any ../attach-p-cmd-p >> "$EXP" &
tracee_pid=$!

while ! [ -s "$EXP" ]; do
	kill -0 $tracee_pid 2> /dev/null ||
		fail_ 'set_ptracer_any ../attach-p-cmd-p failed'
done

run_strace -a30 -echdir -p $tracee_pid ../attach-p-cmd-cmd > "$EXP"
match_diff "$LOG" "$EXP"
