8322 nl: misleading-indentation
[unleashed/tickless.git] / usr / src / cmd / allocate / wdwwrapper.sh
blob2273d63049f6c1becab279656084ad972af67b4a
1 #! /bin/ksh
3 # CDDL HEADER START
5 # The contents of this file are subject to the terms of the
6 # Common Development and Distribution License (the "License").
7 # You may not use this file except in compliance with the License.
9 # You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10 # or http://www.opensolaris.org/os/licensing.
11 # See the License for the specific language governing permissions
12 # and limitations under the License.
14 # When distributing Covered Code, include this CDDL HEADER in each
15 # file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16 # If applicable, add the following below this CDDL HEADER, with the
17 # fields enclosed by brackets "[]" replaced with your own identifying
18 # information: Portions Copyright [yyyy] [name of copyright owner]
20 # CDDL HEADER END
22 # Copyright 2007 Sun Microsystems, Inc. All rights reserved.
23 # Use is subject to license terms.
25 #pragma ident "%Z%%M% %I% %E% SMI"
29 # Script to wrap a non-windowing clean script to provide a prompt
30 # before the dtterm window closes, and to catch abnormal terminations.
32 # For any abnormal termination of the clean script, kill our parent
33 # process so that our grandparent will know that the script did not
34 # terminate normally. (We expect our parent to be dtterm, and our
35 # grandparent to be allocate.)
37 # Trap any signal that would cause abnormal termination of the script,
38 # This catches use of ^C, ^Z, etc., and it also catches the HUP signal
39 # when the dtterm window is closed before the script is finished.
41 PARENT_KILLED=no
43 killparent() {
44 if [ $PARENT_KILLED = "no" ]; then
45 PARENT_KILLED=yes
46 kill -9 $PPID
50 trap "killparent" HUP INT TERM QUIT TSTP ABRT
52 SCRIPT=$1
53 shift
55 if [ ! -e $SCRIPT ]; then
56 echo **** Clean script $SCRIPT not found ****
57 echo "**** Press RETURN to close window ****"
58 read
59 kill -9 $PPID
62 echo "**** Device cleanup for $2 ****\n"
64 $SCRIPT "$@"
65 STAT=$?
67 echo "\n**** Press RETURN to close window ****"
68 read
70 # If the script returned a non-zero exit status, kill our dtterm
71 # parent process.
73 if [ $STAT != 0 ]; then
74 killparent