Bogus PID for client on remote host (Re-Post)
Posted in 1999
This is a repost; The original was mangled by DejaNews but I don't know
how to un-post it. In any case, it generated one e-mailed response. I
have since come up with a solution to my motivating problem and am
posting it here for the benefit of anyone in my quandary.
Original post, hopefully cleaned up.
Hi Family.
I wanted to write a shell script to kill every process connected to the
Informix environment. I planned to do a kill -2 on every PID in the
output of onstat -g ses. (kill -1 won't work on nohup and cron jobs
while kill -9 would not allow them to clean up. But that's another
story.)
While testing this with commands directly from the shell, I found
something interesting - a bad sign. Here is a gleaning from the output:
session #RSAM total used
id user tty pid hostname threads memory memory
7352 root - 0 - 0 8192 4824
7351 root - 0 - 0 8192 4824
7349 stlxa BULLPEN2 -94295 bullpen2 1 40960 28544
7348 root - 0 - 0 8192 4824
7345 bndb 2 16381 clancy 1 32768 29504
7341 root - 0 - 0 8192 4824
7327 onjzk - 3458 tolkien 1 106496 92520
7317 autosys - 16318 clancy 1 49152 41008
7316 autosys - 16273 clancy 1 491520 488320
7305 dbcxw CWILLIAM -4047589 cwilliam 1 40960 28544
7304 dcjlw - 3458 tolkien 1 106496 93424
7297 dbcxw CWILLIAM -4047589 cwilliam 1 212992 129704
7291 tsr044 - 3458 tolkien 1 106496 97320
7285 tsr073 - 3458 tolkien 1 106496 94424
7280 onkas - 3458 tolkien 1 106496 91896
Note that PID 3458 is repeated several times, although the lines it
appears on are clearly different sessions and users. The pattern is
that that host "tolkien" is another machine. (clancy is the DSA system
that I am working on.) The PIDs on the lines with host clancy are
unique and mostly OK, though they may be gone by the time I run the PS.
But that repeated PID 3458 for the clients on another host is a
mystery. It does not represent a process in my system at all.
Note also the negative numbers in the PID field on some other lines.
These are client-server clients like PowerBuilder or something elso
running on PC's. There are many in the actual output.
Bottom line:
How do I kill the remote client? Or rather, how do I sever the
connection so that the remote client knows it has been cut (with an
error message from its side of the connection)?
What does that bogus PID represent anyway?
<<--------------------------------------->>
OK, this got one e-mailed response: Heiko G responded:
>I think what you are looking for is 'onmode -z <sid>', which will
>terminate session <sid> (session id as displayed by onstat -g ses).
>There shouldn't be any reason to use the process id.
Actually, there is a reason. I had not explained my reasons for what I
am trying to do ' this post was long enough without those. But here is
the explanation. (Sighhh..)
I need to set AFDEBUG for an ODS system. When a PANIC occurs, the
oninit processes will all just freeze up, as will the shared memory. I
am writing a shell script to run several onstat commands against this
frozen shared memory. (This is HP-UX; I cannot run the onstat commands
against a shared-memory dump.)
Since this is a 24x7 production system, I also want the script to
manually do the cleanup ' exiting the oninit processes (kill '9 ) and
cleaning up shared memory (ipcrm 'm). I also want to get rid of the
sessions because anyone still attached to shared memory may interfere
with the removal of shared memory segments. (The kernel does not care
that the reason for the attachment is gone.)
The onmode 'z command will not help here. Since shared memory is
frozen, there will be no rollback thread for any transactions in
progress at PANIC time. No, I have to kill the processes myself.
But now that I have cleared the air on why I want to do this all, I
realize that the only possible interference with shared memory removal
are the local clients ' those who are likely to be connected to the
user segment of the shared memory. The socket-connected clients will
not get in the way. And the local clients' PID entries *are* unique
within the onstat 'g ses listing.
Hence, I can kill all front-end local clients with the following
pipeline:
onstat -g ses|
awk '$5 == "clancy" {print $4}' |
xargs kill -2
This isolates the PID of all local clients and kills them.
Of course, my script must be owned by root and have the "set uid" and
gid permission flags set.
OK, I have the solution to my problem. Now what *does* that bogus PID
stand for on the lines with the remote-client sessions?
Thanks for even thinking of helping or for even just reading this
far! ;-)
--
+---- Jacob Salomon DBA JSalomon@bn.com ---------------------+
|(In perpetual pursuit of undomesticated semi-aquatic avians)|
| The expedient performance of a task with excessive concern |
| regarding its duration-to-completion engenders a virtual |
| certainty of diminished benefit therefrom. |
| -- Benjamin Franklin (but he said it in 3 words) |
+------------------------------------------------------------+
Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.