3 # --- T2-COPYRIGHT-NOTE-BEGIN ---
4 # This copyright note is auto-generated by ./scripts/Create-CopyPatch.
6 # T2 SDE: misc/archive/killport.sh
7 # Copyright (C) 2004 - 2005 The T2 SDE Project
8 # Copyright (C) 1998 - 2003 ROCK Linux Project
10 # More information can be found in the files COPYING and README.
12 # This program is free software; you can redistribute it and/or modify
13 # it under the terms of the GNU General Public License as published by
14 # the Free Software Foundation; version 2 of the License. A copy of the
15 # GNU General Public License can be found in the file COPYING.
16 # --- T2-COPYRIGHT-NOTE-END ---
22 xport
="`printf '%04X' $port 2> /dev/null || echo ERROR`"
23 if [ "$xport" = "ERROR" ] ; then
24 echo "Not a valid port number: $port" >&2
25 returncode
=$
(($returncode + 1))
27 echo "Sending signal $signal to all processes connected" \
30 for proto
in tcp udp
; do
31 echo -n " Inodes for `echo $proto | tr a-z A-Z`/$xport: "
32 inodes
=`egrep "^ *[0-9]+: +[0-9A-F]+:$xport " /proc/net/$proto |
33 tr -s ' ' | cut -f11 -d' ' | tr '\n' ' '`
34 if [ "$inodes" ] ; then
35 echo "$inodes (getting pids)"
36 for inode
in $inodes ; do
37 echo -n " PIDs for inode $inode: "
38 pids
="`ls -l /proc/[0-9]*/fd/* 2> /dev/null | \
39 grep 'socket:\['$inode'\]' | tr -s ' ' |
40 cut -f9 -d' ' | cut -f3 -d/ | tr '\n' ' '`"
42 echo "$pids (sending signal)"