ref: f48f36fd06fbf1519076df5b70bb6f5c2e545f8e
parent: 592eeaea689ecedb955ea3d240194528e052f278
author: qwx <qwx@sciops.net>
date: Fri May 27 15:59:09 EDT 2022
lstk: rewrite: enter acid session, or just print; multiple args
--- a/bin/lstk
+++ b/bin/lstk
@@ -1,12 +1,26 @@
#!/bin/rc
rfork n
-if(~ $#* 1){
+print=()
+if(~ $1 -p){
+ print=1
+ shift
+}
+if(~ $#* 0)
+ p=Broken
+if not{
p=$1
shift
}
-if not if(~ $#* 0)
- p=`{ps | grep Broken | awk '{print $2}' | sort -n | tail -n 1}
-if not
- p usage: $0 '[broken]' >[2=1]
-echo lstk'()' | acid -lthread $p
-echo acid -lthread -lpool $* $p
+psd $p
+p=`{psd $p | sed 's/^[^ ]+[ ]+([^ ]+).*/\1/;1q'}
+if(~ $#p 0){
+ echo no proc $p >[1=2]
+ exit noproctohand
+}
+if(! ~ $#print 0){
+ echo lstk'()' | acid -lthread $p
+ echo acid -lthread -lpool $* $p
+}
+if not{
+ {echo lstk'()'; cat} | acid -lthread -lpool $* $p
+}