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