xref: /freebsd-src/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/proc/tst.exitkilled.ksh (revision 98e0ffaefb0f241cda3a72395d3be04192ae0d47)
12be1a816SJohn Birrell#
22be1a816SJohn Birrell# CDDL HEADER START
32be1a816SJohn Birrell#
42be1a816SJohn Birrell# The contents of this file are subject to the terms of the
52be1a816SJohn Birrell# Common Development and Distribution License (the "License").
62be1a816SJohn Birrell# You may not use this file except in compliance with the License.
72be1a816SJohn Birrell#
82be1a816SJohn Birrell# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
92be1a816SJohn Birrell# or http://www.opensolaris.org/os/licensing.
102be1a816SJohn Birrell# See the License for the specific language governing permissions
112be1a816SJohn Birrell# and limitations under the License.
122be1a816SJohn Birrell#
132be1a816SJohn Birrell# When distributing Covered Code, include this CDDL HEADER in each
142be1a816SJohn Birrell# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
152be1a816SJohn Birrell# If applicable, add the following below this CDDL HEADER, with the
162be1a816SJohn Birrell# fields enclosed by brackets "[]" replaced with your own identifying
172be1a816SJohn Birrell# information: Portions Copyright [yyyy] [name of copyright owner]
182be1a816SJohn Birrell#
192be1a816SJohn Birrell# CDDL HEADER END
202be1a816SJohn Birrell#
212be1a816SJohn Birrell
222be1a816SJohn Birrell#
232be1a816SJohn Birrell# Copyright 2007 Sun Microsystems, Inc.  All rights reserved.
242be1a816SJohn Birrell# Use is subject to license terms.
252be1a816SJohn Birrell#
262be1a816SJohn Birrell# ident	"%Z%%M%	%I%	%E% SMI"
272be1a816SJohn Birrell
282be1a816SJohn Birrell#
292be1a816SJohn Birrell# This script tests that the proc:::exit probe fires with the correct argument
302be1a816SJohn Birrell# when the process is killed.
312be1a816SJohn Birrell#
322be1a816SJohn Birrell# If this fails, the script will run indefinitely; it relies on the harness
332be1a816SJohn Birrell# to time it out.
342be1a816SJohn Birrell#
352be1a816SJohn Birrellscript()
362be1a816SJohn Birrell{
372be1a816SJohn Birrell	$dtrace -s /dev/stdin <<EOF
382be1a816SJohn Birrell	proc:::exit
392be1a816SJohn Birrell	/curpsinfo->pr_ppid == $child &&
402be1a816SJohn Birrell	    curpsinfo->pr_psargs == "$longsleep" && args[0] == CLD_KILLED/
412be1a816SJohn Birrell	{
422be1a816SJohn Birrell		exit(0);
432be1a816SJohn Birrell	}
442be1a816SJohn BirrellEOF
452be1a816SJohn Birrell}
462be1a816SJohn Birrell
472be1a816SJohn Birrellsleeper()
482be1a816SJohn Birrell{
492be1a816SJohn Birrell	while true; do
502be1a816SJohn Birrell		$longsleep &
51*9ed9976cSMark Johnston		sleep 1
522be1a816SJohn Birrell		kill -9 $!
532be1a816SJohn Birrell	done
542be1a816SJohn Birrell}
552be1a816SJohn Birrell
562be1a816SJohn Birrellif [ $# != 1 ]; then
572be1a816SJohn Birrell	echo expected one argument: '<'dtrace-path'>'
582be1a816SJohn Birrell	exit 2
592be1a816SJohn Birrellfi
602be1a816SJohn Birrell
612be1a816SJohn Birrelldtrace=$1
62*9ed9976cSMark Johnstonlongsleep="/bin/sleep 10000"
632be1a816SJohn Birrell
642be1a816SJohn Birrellsleeper &
652be1a816SJohn Birrellchild=$!
662be1a816SJohn Birrell
672be1a816SJohn Birrellscript
682be1a816SJohn Birrellstatus=$?
692be1a816SJohn Birrell
70*9ed9976cSMark Johnstonkill -STOP $child
712be1a816SJohn Birrellpkill -P $child
722be1a816SJohn Birrellkill $child
73*9ed9976cSMark Johnstonkill -CONT $child
742be1a816SJohn Birrell
752be1a816SJohn Birrellexit $status
76