xref: /onnv-gate/usr/src/cmd/dtrace/test/tst/common/pid/tst.fork.d (revision 3944:75371f172291)
12633Sahl /*
22633Sahl  * CDDL HEADER START
32633Sahl  *
42633Sahl  * The contents of this file are subject to the terms of the
52633Sahl  * Common Development and Distribution License (the "License").
62633Sahl  * You may not use this file except in compliance with the License.
72633Sahl  *
82633Sahl  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
92633Sahl  * or http://www.opensolaris.org/os/licensing.
102633Sahl  * See the License for the specific language governing permissions
112633Sahl  * and limitations under the License.
122633Sahl  *
132633Sahl  * When distributing Covered Code, include this CDDL HEADER in each
142633Sahl  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
152633Sahl  * If applicable, add the following below this CDDL HEADER, with the
162633Sahl  * fields enclosed by brackets "[]" replaced with your own identifying
172633Sahl  * information: Portions Copyright [yyyy] [name of copyright owner]
182633Sahl  *
192633Sahl  * CDDL HEADER END
202633Sahl  */
212633Sahl 
222633Sahl /*
23*3944Sahl  * Copyright 2007 Sun Microsystems, Inc.  All rights reserved.
242633Sahl  * Use is subject to license terms.
252633Sahl  */
262633Sahl 
272633Sahl #pragma ident	"%Z%%M%	%I%	%E% SMI"
282633Sahl 
292633Sahl /*
302633Sahl  * ASSERTION: make sure fork(2) is okay
312633Sahl  *
322633Sahl  * SECTION: pid provider
332633Sahl  */
342633Sahl 
352633Sahl #pragma D option destructive
362633Sahl 
372633Sahl pid$1:a.out:waiting:entry
382633Sahl {
392633Sahl 	this->value = (int *)alloca(sizeof (int));
402633Sahl 	*this->value = 1;
412633Sahl 	copyout(this->value, arg0, sizeof (int));
422633Sahl }
432633Sahl 
44*3944Sahl proc:::create
45*3944Sahl /pid == $1/
462633Sahl {
47*3944Sahl 	child = args[0]->pr_pid;
482633Sahl 	trace(pid);
492633Sahl }
502633Sahl 
512633Sahl pid$1:a.out:go:
522633Sahl /pid == child/
532633Sahl {
542633Sahl 	trace("wrong pid");
552633Sahl 	exit(1);
562633Sahl }
572633Sahl 
58*3944Sahl proc:::exit
592633Sahl /pid == $1 || pid == child/
602633Sahl {
612633Sahl 	out++;
622633Sahl 	trace(pid);
632633Sahl }
642633Sahl 
65*3944Sahl proc:::exit
662633Sahl /out == 2/
672633Sahl {
682633Sahl 	exit(0);
692633Sahl }
702633Sahl 
712633Sahl 
722633Sahl BEGIN
732633Sahl {
742633Sahl 	/*
752633Sahl 	 * Let's just do this for 5 seconds.
762633Sahl 	 */
772633Sahl 	timeout = timestamp + 5000000000;
782633Sahl }
792633Sahl 
802633Sahl profile:::tick-4
812633Sahl /timestamp > timeout/
822633Sahl {
832633Sahl 	trace("test timed out");
842633Sahl 	exit(1);
852633Sahl }
862633Sahl 
87