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 tests that -- if a exec(2) fails -- the proc:::exec probe fires, 302633Sahl# followed by the proc:::exec-success probe (in a successful exec(2)). To 312633Sahl# circumvent any potential shell cleverness, this script generates exec 322633Sahl# failure by generating a file with a bogus interpreter. (It seems unlikely 332633Sahl# that a shell -- regardless of how clever it claims to be -- would bother to 342633Sahl# validate the interpreter before exec'ing.) 352633Sahl# 362633Sahl# If this fails, the script will run indefinitely; it relies on the harness 372633Sahl# to time it out. 382633Sahl# 392633Sahlscript() 402633Sahl{ 412633Sahl $dtrace -s /dev/stdin <<EOF 422633Sahl proc:::exec 432633Sahl /curpsinfo->pr_ppid == $child && args[0] == "$badexec"/ 442633Sahl { 452633Sahl self->exec = 1; 462633Sahl } 472633Sahl 482633Sahl proc:::exec-failure 492633Sahl /self->exec/ 502633Sahl { 512633Sahl exit(0); 522633Sahl } 532633SahlEOF 542633Sahl} 552633Sahl 562633Sahlsleeper() 572633Sahl{ 582633Sahl while true; do 592633Sahl /usr/bin/sleep 1 602633Sahl $badexec 612633Sahl done 622633Sahl} 632633Sahl 642804Stomeeif [ $# != 1 ]; then 652804Stomee echo expected one argument: '<'dtrace-path'>' 662804Stomee exit 2 672804Stomeefi 682804Stomee 692633Sahlbadexec=/tmp/execfail.ksh.$$ 702804Stomeedtrace=$1 712633Sahl 722633Sahlcat > $badexec <<EOF 732633Sahl#!/this_is_a_bogus_interpreter 742633SahlEOF 752633Sahl 762633Sahlchmod +x $badexec 772633Sahl 782633Sahlsleeper & 792633Sahlchild=$! 802633Sahlscript 812633Sahlstatus=$? 822633Sahl 832633Sahlkill $child 842633Sahlrm $badexec 852633Sahl 862633Sahlexit $status 87