Created
July 10, 2013 20:18
-
-
Save jperkin/5969911 to your computer and use it in GitHub Desktop.
dtruss -F option
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- /usr/bin/dtruss 2012-02-22 00:58:47.000000000 +0000 | |
+++ dtruss.dashF 2013-07-10 21:16:03.000000000 +0100 | |
@@ -6,7 +6,7 @@ | |
# | |
# 17-Jun-2005, ver 0.80 (check for newer versions) | |
# | |
-# USAGE: dtruss [-acdeflhoLs] [-t syscall] { -p PID | -n name | command } | |
+# USAGE: dtruss [-acdeflhoLs] [-F outfile] [-t syscall] { -p PID | -n name | command } | |
# | |
# -p PID # examine this PID | |
# -n name # examine this process name | |
@@ -15,6 +15,7 @@ | |
# -c # print system call counts | |
# -d # print relative timestamps (us) | |
# -e # print elapsed times (us) | |
+# -F outfile # send output to filename (default is stderr) | |
# -f # follow children as they are forked | |
# -l # force printing of pid/lwpid per line | |
# -o # print on cpu times (us) | |
@@ -72,9 +73,10 @@ | |
opt_relative=0; opt_printid=0; opt_follow=0 | |
opt_command=0; command=""; opt_buf=0; buf="4m" | |
opt_trace=0; trace="."; opt_stack=0; | |
+opt_outfile="/dev/stderr" | |
### Process options | |
-while getopts ab:cdefhln:op:st:L name | |
+while getopts ab:cdeF:fhln:op:st:L name | |
do | |
case $name in | |
b) opt_buf=1; buf=$OPTARG ;; | |
@@ -86,13 +88,14 @@ | |
c) opt_counts=1 ;; | |
d) opt_relative=1 ;; | |
e) opt_elapsed=1 ;; | |
+ F) opt_outfile=$OPTARG ;; | |
f) opt_follow=1 ;; | |
l) opt_printid=1 ;; | |
o) opt_cpu=1 ;; | |
L) opt_printid=-1 ;; | |
s) opt_stack=-1 ;; | |
h|?) cat <<-END >&2 | |
- USAGE: dtruss [-acdefholLs] [-t syscall] { -p PID | -n name | command } | |
+ USAGE: dtruss [-acdefholLs] [-F outfile] [-t syscall] { -p PID | -n name | command } | |
-p PID # examine this PID | |
-n name # examine this process name | |
@@ -101,6 +104,7 @@ | |
-c # print syscall counts | |
-d # print relative times (us) | |
-e # print elapsed times (us) | |
+ -F outfile # send output to filename | |
-f # follow children | |
-l # force printing pid/lwpid | |
-o # print on cpu times | |
@@ -678,11 +682,9 @@ | |
#fi | |
### Run DTrace (Mac OS X) | |
-# Redirect the output to /dev/stderr so that it doesn't mingle with | |
-# data going to the target's stdout | |
if [ $opt_command -eq 1 ]; then | |
/usr/sbin/dtrace -x dynvarsize=$buf -x evaltime=exec -n "$dtrace" \ | |
- -c "$command" -o /dev/stderr | |
+ -c "$command" -o "$opt_outfile" | |
else | |
- /usr/sbin/dtrace -x dynvarsize=$buf -n "$dtrace" -o /dev/stderr | |
+ /usr/sbin/dtrace -x dynvarsize=$buf -n "$dtrace" -o "$opt_outfile" | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment