kill the tty


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting kill the tty
# 1  
Old 04-08-2004
kill the tty

Hello Experts
i'm having some trouble with a script.
the purpose is to kill all processes from a distinct tty in a HP-UX machine, given the User TTY.

it's to use like this:

killtty pts/tnb pts/tr pts/tD

here it is

#!/usr/bin/ksh
i=1
for i
do
[ ${i} ] || exit
kill -9 `ps -ft "${i}" | awk 'NR != 1 {print $2}'`
done

The problem is that it's leaving a zombie process, i don't know why.

i have adapted this script from one that Perderabo has indicated to me to kill all processes from a user given it's UserName.

Thanks for your help
# 2  
Old 04-08-2004
A true zombie is not much of a problem. But look at the ppid field of the zombie. Do a ps "-fp n" where n is that ppid of the zombie. You will now be looking at the parent of the zombie. The zombie will persist until the parent issues a wait() system call. If the program is allowing zomblies to accumulate, it needs a fix. And you cam kill this parent process. That will reparent the zombie to init which will always wait for a dead child.
# 3  
Old 04-08-2004
well , let's see
when i use this script, it kill's all the processes but one.
the user still appears when i use "who" and with "w" in the column "what" i have "-".using "who -u" it has a process number.
and when i try to make "ps -fu" on that number , nothing appears.
i'm a bit confused about this, so i'l try to understand this a litlle bit more. thanks Perderabo
# 4  
Old 04-08-2004
Quote:
Originally posted by vascobrito
"ps -fu" on that number , nothing appears.
i'm a bit confused about this,
ps -fp
# 5  
Old 04-08-2004
sorry, i ment to write ps -fp
when i write "who -u" , this appears:

dist12 pts/tc Apr 8 17:03 0:35 8145 132.142.170.33

then i try to:

"ps -fp 8145", but nothing appears, just column headers.

even when i write "ps -u dist12", nothing appears.

When i write "w", it appears among all other users

User tty login@ idle JCPU PCPU What
dist12 pts/tc 5:03 37 -

there must be some script error ,like if the script was killing the processes in the wrong order.
# 6  
Old 04-08-2004
Huh? What on earth does "who" have to do with anything? A zombie is a process that has terminated. You use "ps" to see processes. In "ps -el", the second field, labelled S (for state) will have a Z for any zombies. So "ps -el | grep Z" will give you a list of all of your zombies...if you actually have some.
# 7  
Old 04-08-2004
well , i usualy use "who" to find who is logged.
when that line appears...

User tty login@ idle JCPU PCPU What
dist12 pts/tc 5:03 37 -

with that "-" in 7 column, the user isn't logged and i can't kill him any way, everything i try it's unusefull and the olny process number i can get is when i use "who -u". In this case it shows :

dist12 pts/tc Apr 8 17:03 6:42 8145 132.142.170.33

the number "8145" is the only PID that i find.

i don't know if this is a zombie, but i sure can't do anything with it.

as to knowledge about Unix or Scripting, don't be surprise about my ignorance. I only started while ago to learn.

and you have been most helpfull Perderabo
thanks for that
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Python: Redirecting to tty and reading from tty

In bash, you can do something like this: #!/bin/bash echo -n "What is your name? " > /dev/tty read thename < /dev/tty How can I do the same in python? I have a python script that has the following content: #!/usr/bin/python2.7 import getpass import sys import telnetlib import... (2 Replies)
Discussion started by: SkySmart
2 Replies

2. Shell Programming and Scripting

Kill an specific process ID using the KILL and GREP commands

Good afternoon I need to KILL a process in a single command sentence, for example: kill -9 `ps -aef | grep 'CAL255.4ge' | grep -v grep | awk '{print $2}'` That sentence Kills the process ID corresponding to the program CAL255.4ge. However it is possible that the same program... (6 Replies)
Discussion started by: enriquegm82
6 Replies

3. Solaris

Cannot kill a process with kill -9

Hello everyone, I have a process that I want to kill. I have tried kill-9 PID but it doesn't work. I have tried preap PID but it doesn't work too. The parent of my process is the process whose PID is 1, so I can't kill it. My OS is a Solaris 9. Can anyone help me understand what's going... (3 Replies)
Discussion started by: adilyos
3 Replies

4. UNIX for Advanced & Expert Users

imposible to kill a tty

Hello. We have a hp-ux 11i server , when i run who -u the output command show to me a old session as: xxx pts/t0 Feb 12 13:53 old 13040 xx.xxx.xx.xx when i try to kill with kill -9 13040 i receive this message kill: 13040: The specified process does not exist I've... (5 Replies)
Discussion started by: ct2marer
5 Replies

5. Linux

Kill a process without using kill command

I want to Kill a process without using kill command as i don't have privileges to kill the process. I know the pid and i am using Linux 2.6.9 OS. (6 Replies)
Discussion started by: sudhamacs
6 Replies

6. Shell Programming and Scripting

Kill a process without using kill command

Sorry, posted the question in other forum. (0 Replies)
Discussion started by: sudhamacs
0 Replies

7. UNIX for Advanced & Expert Users

Diff b/n kill and kill -9

Hi, I have a process with say pid x. What is the difference b/n kill x and kill -9 x in unix Thanks Ammu (2 Replies)
Discussion started by: ammu
2 Replies

8. Programming

kill(0,-9) don't kill the process

Hi all i have simple c program , when i wish to kill the app im using kill(0,-9) , but it seams this command don't do any thing and the program. just ignore it . what im doing wrong here ? im using HP-UX ia64 Thanks (9 Replies)
Discussion started by: umen
9 Replies

9. UNIX for Dummies Questions & Answers

not able to kill find with kill -9

Hello everyone I am using HP Ux and had run a find command. Now I am trying to kill it with kill or kill -9 but it is not getting killed and still running. Any clues ? Thanks Sidhu (5 Replies)
Discussion started by: Amardeep
5 Replies

10. UNIX for Advanced & Expert Users

When kill doesnt work, how to kill a process ?

Hi All, I am unable to kill a process using kill command. I am using HP-UX system. I have tried with kill -9 and i have root privilages. How can i terminate this daemon ? ? ? Regards, Vijay Hegde (3 Replies)
Discussion started by: VijayHegde
3 Replies
Login or Register to Ask a Question