1#!/bin/sh 2 3base=`basename $0` 4 5echo "1..2" 6 7name="pgrep -t <tty>" 8tty=`ps -x -o tty -p $$ | tail -1` 9if [ "$tty" = "??" -o "$tty" = "-" ]; then 10 tty="-" 11 ttyshort="-" 12else 13 case $tty in 14 pts/*) ttyshort=`echo $tty | cut -c 5-` ;; 15 *) ttyshort=`echo $tty | cut -c 4-` ;; 16 esac 17fi 18sleep=$(pwd)/sleep.txt 19ln -sf /bin/sleep $sleep 20$sleep 5 & 21sleep 0.3 22chpid=$! 23pid=`pgrep -f -t $tty $sleep` 24if [ "$pid" = "$chpid" ]; then 25 echo "ok 1 - $name" 26else 27 echo "not ok 1 - $name" 28fi 29pid=`pgrep -f -t $ttyshort $sleep` 30if [ "$pid" = "$chpid" ]; then 31 echo "ok 2 - $name" 32else 33 echo "not ok 2 - $name" 34fi 35kill $chpid 36rm -f $sleep 37