tst.taskid.ksh revision 256281
19769Spsandoz#!/bin/ksh -p 212777Spsandoz# 39769Spsandoz# CDDL HEADER START 49769Spsandoz# 59769Spsandoz# The contents of this file are subject to the terms of the 69769Spsandoz# Common Development and Distribution License (the "License"). 79769Spsandoz# You may not use this file except in compliance with the License. 89769Spsandoz# 99769Spsandoz# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 109769Spsandoz# or http://www.opensolaris.org/os/licensing. 119769Spsandoz# See the License for the specific language governing permissions 129769Spsandoz# and limitations under the License. 139769Spsandoz# 149769Spsandoz# When distributing Covered Code, include this CDDL HEADER in each 159769Spsandoz# file and include the License file at usr/src/OPENSOLARIS.LICENSE. 169769Spsandoz# If applicable, add the following below this CDDL HEADER, with the 179769Spsandoz# fields enclosed by brackets "[]" replaced with your own identifying 189769Spsandoz# information: Portions Copyright [yyyy] [name of copyright owner] 199769Spsandoz# 209769Spsandoz# CDDL HEADER END 219769Spsandoz# 229769Spsandoz 239769Spsandoz# 249769Spsandoz# Copyright 2006 Sun Microsystems, Inc. All rights reserved. 259769Spsandoz# Use is subject to license terms. 269769Spsandoz# 279769Spsandoz 2811707Stpivovarova#ident "%Z%%M% %I% %E% SMI" 2912290Salanb 3011707Stpivovarova############################################################################ 3111707Stpivovarova# ASSERTION: 3211707Stpivovarova# To verify taskid of current process. 3311707Stpivovarova# 349769Spsandoz# SECTION: Scripting 359769Spsandoz# 3611707Stpivovarova############################################################################ 3711707Stpivovarova 389769Spsandozif [ $# != 1 ]; then 399769Spsandoz echo expected one argument: '<'dtrace-path'>' 409769Spsandoz exit 2 419769Spsandozfi 429769Spsandoz 439769Spsandozdtrace=$1 449769Spsandozbname=`/bin/basename $0` 459769Spsandozdfilename=/var/tmp/$bname.$$ 4611180Sshade 479769Spsandoz## Create .d file 489769Spsandoz########################################################################## 499769Spsandozcat > $dfilename <<-EOF 509769Spsandoz#!$dtrace -qs 519769Spsandoz 529769Spsandoz 539769SpsandozBEGIN 549769Spsandoz/\$taskid != \$1/ 559769Spsandoz{ 569769Spsandoz exit(1); 579769Spsandoz} 589769Spsandoz 599769SpsandozBEGIN 609769Spsandoz/\$taskid == \$1/ 619769Spsandoz{ 629769Spsandoz exit(0); 639769Spsandoz} 649769SpsandozEOF 659769Spsandoz########################################################################## 669769Spsandoz 679769Spsandoz 689769Spsandoz#Call dtrace -C -s <.d> 699769Spsandoz 709769Spsandozchmod 555 $dfilename 719769Spsandoz 729769Spsandoztaskidval=`ps -o pid,taskid | grep "$$ " | awk '{print $2}' 2>/dev/null` 739769Spsandozif [ $? -ne 0 ]; then 749769Spsandoz print -u2 "unable to get uid of the current process with pid = $$" 759769Spsandoz exit 1 769769Spsandozfi 779769Spsandoz 789769Spsandoz$dfilename $taskidval >/dev/null 2>&1 799769Spsandoz 809769Spsandozif [ $? -ne 0 ]; then 819769Spsandoz print -u2 "Error in executing $dfilename" 829769Spsandoz exit 1 839769Spsandozfi 849769Spsandoz 859769Spsandoz#/bin/rm -f $dfilename 869769Spsandozexit 0 879769Spsandoz