plan9fox/rc/bin/tap

47 lines
647 B
Text
Raw Normal View History

2012-03-09 22:10:17 +00:00
#!/bin/rc
v=()
fn otherqid {
x=`{echo $1 | sed 's/[12]$//'}
switch($1){
case $x^1
echo $x^2
case $x^2
echo $x^1
}
}
fn traceqid {
while(! ~ $#* 0){
2012-03-09 22:56:05 +00:00
echo '['$2']' $3 $1
2012-03-09 22:10:17 +00:00
tracepid `{grep -n `{otherqid $1} /proc/*/fd | sed 's!^/proc/([^/]+)/.*!\1!g'} \
| sed 's/^/ /g'
shift
shift
2012-03-09 22:56:05 +00:00
shift
2012-03-09 22:10:17 +00:00
}
}
fn tracepid {
while(! ~ $#* 0){
echo $1 `{cat /proc/$1/args >[2]/dev/null}
switch($1){
case $v
echo ' ...'
case *
v=($1 $v)
2012-03-09 22:56:05 +00:00
traceqid `{awk '/\|/{q=substr($5,2);print q" "$1" "$10}' /proc/$1/fd} \
2012-03-09 22:10:17 +00:00
| sed 's/^/ /g'
}
shift
}
}
if(~ $#* 0){
echo 'Usage: ' $0 '[ pid ... ]' >[1=2]
exit usage
}
tracepid $*