]> CyberLeo.Net >> Repos - FreeBSD/releng/10.0.git/blob - tools/regression/usr.bin/pkill/pgrep-t.t
- Copy stable/10 (r259064) to releng/10.0 as part of the
[FreeBSD/releng/10.0.git] / tools / regression / usr.bin / pkill / pgrep-t.t
1 #!/bin/sh
2 # $FreeBSD$
3
4 base=`basename $0`
5
6 echo "1..2"
7
8 name="pgrep -t <tty>"
9 tty=`ps -o tty -p $$ | tail -1`
10 if [ "$tty" = "??" ]; then
11         tty="-"
12         ttyshort="-"
13 else
14         case $tty in
15         pts/*)  ttyshort=`echo $tty | cut -c 5-` ;;
16         *)      ttyshort=`echo $tty | cut -c 4-` ;;
17         esac
18 fi
19 sleep=`mktemp /tmp/$base.XXXXXX` || exit 1
20 ln -sf /bin/sleep $sleep
21 $sleep 5 &
22 sleep 0.3
23 chpid=$!
24 pid=`pgrep -f -t $tty $sleep`
25 if [ "$pid" = "$chpid" ]; then
26         echo "ok 1 - $name"
27 else
28         echo "not ok 1 - $name"
29 fi
30 pid=`pgrep -f -t $ttyshort $sleep`
31 if [ "$pid" = "$chpid" ]; then
32         echo "ok 2 - $name"
33 else
34         echo "not ok 2 - $name"
35 fi
36 kill $chpid
37 rm -f $sleep