usttrace: enhance
[ust.git] / usttrace
index c77f73114ae97d6e2db7f431f4f03c9714a17dd7..689cdded2f66b3289f661e2f9ed003a5a9038ac9 100755 (executable)
--- a/usttrace
+++ b/usttrace
@@ -3,13 +3,14 @@
 # usttrace  by Pierre-Marc Fournier 2009
 # Distributed under the GPLv2.
 
-USTD="./ustd/ustd"
-LIBINTERFORK_PATH="./libinterfork/.libs/libinterfork.so"
-LIBMALLOCWRAP_PATH="./libmallocwrap/.libs/libmallocwrap.so"
+USTTRACE_DIR="$(dirname $0)"
+USTD="${USTTRACE_DIR}/ustd/ustd"
+LIBINTERFORK_PATH="${USTTRACE_DIR}/libinterfork/.libs/libinterfork.so"
+LIBMALLOCWRAP_PATH="${USTTRACE_DIR}/libmallocwrap/.libs/libmallocwrap.so"
 
-STD_LDLIBRARY_UST="./libust/.libs:../liburcu"
+STD_LDLIBRARY_UST="${USTTRACE_DIR}/libust/.libs"
 
-BASE_TRACE_DIR="$HOME/.usttraces"
+BASE_TRACE_DIR="${HOME}/.usttraces"
 
 function usage () {
        echo "usage:  $0 OPTIONS COMMAND" 2>/dev/stderr
@@ -36,14 +37,20 @@ while getopts ":hlLmfs" options; do
                s) arg_syswide_daemon=1;;
                h) usage;
                   exit 0;;
-               \?) echo $usage
+               \?) usage
                        exit 1;;
-               *) echo $usage
+               *) usage
                        exit 1;;
        esac
 done
 shift $(($OPTIND - 1))
 
+if [ ! -x "$USTD" ];
+then
+       error "specified path to ustd not executable ($USTD)"
+       exit 1
+fi
+
 # Prepare vars
 CMD=$1
 
@@ -79,7 +86,10 @@ fi
 # Wait for the daemon to settle
 # If we don't, the process may try to connect to its socket before
 # it's ready.
-# FIXME: is there a way to make sure this works every time?
+# FIXME: is there a way to make sure this works every time? Yes,
+# we could have a mode where ustd daemonizes itself. Therefore
+# by the time the control returns to the console, it's ready.
+
 sleep 0.5
 
 # Establish the environment for the command
This page took 0.022919 seconds and 4 git commands to generate.