etc/services - sync with NetBSD-8
[minix.git] / crypto / external / bsd / heimdal / dist / tests / kdc / leaks-kill.sh
blobe67d274f5e7444e91549ade5f2788524d7646dcc
1 #!/bin/sh
3 name=$1
4 pid=$2
6 ec=0
8 if [ "$(uname -s)" = "Darwin" ] ; then
9 echo "leaks check on $name ($pid)"
10 leaks -exclude __CFInitialize $pid > leaks-log 2>&1 || \
11 { echo "leaks failed: $?"; cat leaks-log; exit 1; }
13 env pid=${pid} \
14 perl -e 'my $excluded = 0; my $num = -1; while (<>) {
15 if (/Process $ENV{pid}: (\d+) leaks for \d+ total leaked bytes/) { $num = $1;}
16 if (/(\d+) leaks excluded/) { $excluded = $1;}
18 exit 1 if ($num != 0 && $num != $excluded);
19 exit 0;' leaks-log || \
20 { echo "Memory leak in $name" ; echo ""; cat leaks-log; ec=1; }
22 # [ "$ec" != "0" ] && { env PS1=": leaks-debugger !!!! ; " bash ; }
26 kill $pid
27 sleep 3
28 kill -9 $pid 2> /dev/null
30 rm -f leaks-log
32 exit $ec