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*4926Sjhaslam# Copyright 2007 Sun Microsystems, Inc.  All rights reserved.
242633Sahl# Use is subject to license terms.
252633Sahl#
26*4926Sjhaslam# ident	"%Z%%M%	%I%	%E% SMI"
272633Sahl
282633Sahl#
292633Sahl# This script is identical to tst.execfail.ksh -- but it additionally checks
302633Sahl# that errno is set to ENOENT in the case that an interpreter can't be
312633Sahl# found.
322633Sahl#
332633Sahl# If this fails, the script will run indefinitely; it relies on the harness
342633Sahl# to time it out.
352633Sahl#
362633Sahlscript()
372633Sahl{
382633Sahl	$dtrace -s /dev/stdin <<EOF
392633Sahl	proc:::exec
402633Sahl	/curpsinfo->pr_ppid == $child && args[0] == "$badexec"/
412633Sahl	{
422633Sahl		self->exec = 1;
432633Sahl	}
442633Sahl
452633Sahl	proc:::exec-failure
462633Sahl	/self->exec && args[0] == ENOENT/
472633Sahl	{
482633Sahl		exit(0);
492633Sahl	}
502633SahlEOF
512633Sahl}
522633Sahl
532633Sahlsleeper()
542633Sahl{
552633Sahl	while true; do
562633Sahl		/usr/bin/sleep 1
572633Sahl		$badexec
582633Sahl	done
592633Sahl}
602633Sahl
612804Stomeeif [ $# != 1 ]; then
622804Stomee	echo expected one argument: '<'dtrace-path'>'
632804Stomee	exit 2
642804Stomeefi
652804Stomee
662633Sahlbadexec=/tmp/execfail.ENOENT.ksh.$$
672804Stomeedtrace=$1
682633Sahl
692633Sahlcat > $badexec <<EOF
702633Sahl#!/this_is_a_bogus_interpreter
712633SahlEOF
722633Sahl
732633Sahlchmod +x $badexec
742633Sahl
752633Sahlsleeper &
762633Sahlchild=$!
772633Sahl
782633Sahlscript
792633Sahlstatus=$?
802633Sahl
812633Sahlkill $child
822633Sahlrm $badexec
832633Sahl
842633Sahlexit $status
85