shithub: riscv

Download patch

ref: 0812a26f0057bb20d1220cd3fae310f57fd82b1d
parent: f02f05ca6a7a60a087a9fb7d6b2e81ff820e2d80
author: stanley lieber <stanley.lieber@gmail.com>
date: Mon Apr 14 15:05:57 EDT 2014

add /rc/bin/aanuke

--- /dev/null
+++ b/rc/bin/aanuke
@@ -1,0 +1,6 @@
+#!/bin/rc
+rfork e
+for(i in `{ps | grep -e '[ ]+aan$' | awk '{print $2}'}){
+	if(! grep -s -e '[ ]+\/net\/tcp\/[0-9]+\/data$' /proc/$i/fd)
+		echo '@{echo kill>/proc/'$i'/note} # aan (idle)'
+}
--- a/sys/man/8/aan
+++ b/sys/man/8/aan
@@ -1,6 +1,6 @@
 .TH AAN 8
 .SH NAME
-aan \- always available network
+aan, aanuke \- always available network
 .SH SYNOPSIS
 .B aan
 .B -c
@@ -19,6 +19,7 @@
 [
 .B -m maxto
 ]
+.B aanuke
 .I netdir
 .SH DESCRIPTION
 .I Aan
@@ -64,7 +65,22 @@
 .IR import (4)
 and
 .IR cpu (1).
-.SH EXAMPLE
+.PP
+.I Aanuke
+prints commands that will cause all processes called
+.I aan
+that are owned by the current user and do not have an
+active tcp connection to be terminated.
+Use the
+.B send
+command of
+.IR rio (1),
+or pipe the output of
+.I kill
+into
+.IR rc (1)
+to execute the commands.
+.SH EXAMPLES
 Assume the server part of
 .I aan
 is encapsulated in
@@ -89,6 +105,14 @@
 .EX
 import -p astro6 / /mnt/term
 .EE
+.PP
+Kill idle instances of
+.I aan
+left behind by a terminal that has been powered off:
+.IP
+.EX
+aanuke | rc
+.EE
 .SH FILES
 .TF /sys/log/aan
 .TP
@@ -96,6 +120,8 @@
 Log file
 .SH SOURCE
 .B /sys/src/cmd/aan.c
+.br
+.B /rc/bin/aanuke
 .SH SEE ALSO
 .IR import (4),
 .IR exportfs (4),