-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhpmwatch
executable file
·69 lines (57 loc) · 1.31 KB
/
hpmwatch
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
#!/bin/sh
#$Id: installwatch,v 0.6.1.1 2001/06/25 05:29:45 izto Exp $
set -e
LIBHPM=`dirname "$0"`/../lib/libhpmwatch.so
if ! test -e "$LIBHPM"; then
LIBHPM=`dirname "$0"`/libhpmwatch.so
if ! test -e "$LIBHPM"; then
echo "Error: cannot find libhpmwatch.so"
exit 1
fi
fi
if test -z "$1" ; then
echo "Syntax: $0 [-o outfile] <program> <arguments>"
exit 1
fi
# Define realpath function for compatibility.
realpath() {
if [[ -d "$1" ]]; then
pushd "$1" >/dev/null
pwd
popd >/dev/null
elif [[ -e "$1" ]]; then
pushd `dirname $1` >/dev/null
echo `pwd`/`basename $1`
popd >/dev/null
else
echo $1 does not exist! >&2
exit 1
fi
}
if test "$1" = "-o" ; then
shift
INSTALLWATCHFILE="$1"
if test -z "$INSTALLWATCHFILE" ; then
echo "Syntax: $0 [-o outfile] <program> <arguments>"
exit 1
fi
# If $INSTALLWATCHFILE is a relative path, it must become
# absolute
INSTALLWATCHFILE=`readlink -f $INSTALLWATCHFILE`
export INSTALLWATCHFILE
if ! echo -n > "$INSTALLWATCHFILE" ; then
echo Unable to prepare $INSTALLWATCHFILE
exit 1
fi
shift
fi
if test -z "$*" ; then
echo "Syntax: $0 [-o outfile] <program> <arguments>"
exit 1
fi
if test -u $1 ; then
echo "Warning: $0 may not work with suid programs"
fi
LD_PRELOAD=$LIBHPM "$@"
RET=$?
exit $RET