[SOLVED] Funny : why can't I kill my parent terminal in a script ?
Hellooooooo
Today I've created a script that does some things (not important).
And for fun I want that it kills the terminal from which I launch it. (too lazy to press Alt-F4 lol)
So I write
but it doesn't work ... while if in my xterm I launch another xterm and in this second xterm I write
both xterm windows are closing.
I could manage to make my script work with the "-9" option ... but I don't like to use this way
I really would like to understand that mystery ... if someone may help me please ^_^
you can give a try with and without this line exec bash
and also add the line
Wanna kill your parents ? Maybe i am wrong but i think it is forbidden by design (security reason, generation of zombie process, ressource waste...)
(This is maybe possible with some tools developped in C ?)
I am sure some C guys can tell you more
for a definitive suicide (don't do it if you don't understand what it does or if you don't have another user that can alter the user you modify) :
I've also read the following caveat referenced in the Oreilly Power Tool book purchase it and read the section "Killing All Your Processes " (chapter 38.12)
also
Finally, I found my "error" or maybe I should say another way. It wasn't the PPID I had to kill ... but the PPPID x) and I can kill it without any trouble contrary to PPID.
Here is my script : "launch-and-kill-terminal-window"
then you can launch any program from your terminal wihtout having to close your terminal window manually
for example:
et voilą
just my xclock window... no more xterm window
NB this works well in xterm ... in a gnome-terminal, it closes ALL your gnome-terminal windows, cause gnome-terminal works differently from xterm (again an example why you should use standards :P)
@ctsgnb
I think the line
is important in a script as not evrybody use bash by default. And depending on the interpreter some things change. for example if I remeber tcsh uses variables differently from bash
I've tried with exec but I didn't manage to make it work as I wanted
@ygemici thank you very much for your script. very nice tricks I'll add to my script
I thought it bizzare you had to use PPID and not the terminal's own ID, but you're right: An interactive shell just swallows SIGINT, SIGTERM, SIGQUIT, and sometimes even SIGHUP! There doesn't seem to be any graceful way to kill these things, which is weird.
HI i would like to know how i can simulate a shell scripts for my requirement.
example
Server name child Process id Parent Process id
Vpesh 16013 15637
Server name child Process id Parent Process id
Vpesh 16014 15637
Server name child... (1 Reply)
Hello elite shell/bash specialists,
I have done plenty of STFW and some RTFM, but I cannot find a clear solution to my challenge
Goal:
My goal is to have a script(of any language, preferably shell/bash/anything that can run things on unix), which will kill specific unix terminal windows for... (0 Replies)
I am trying to kill PIDs that are tied to a KSH "load_sqlplus" and I am using the below code
LIST_PID=`ps -ef | grep -i "load_sqlplus" | grep -v grep | awk '{print $2}'`
if ; then
echo "Processes killed" "PID : " $LIST_PID
kill -9 $LIST_PID
else
echo "Nothing to Kill"
fi... (4 Replies)
Hi everyone
i am very new to linux , working on bash shell.
I am trying to solve the given problem
1. Create a process and then create children using fork
2. Check the Status of the application for successful running.
3. Kill all the process(threads) except parent and first child... (2 Replies)
Hi,
I've a script which kills all process, but i need a script shell script(sh), where it'll kill process on that particular terminal. below is example
TY=`tty`
for P in $TY
do
`kill -9 $P 2>/dev/null`;
done
echo "test process killed"
break
... (3 Replies)
Consider this simple command line
bash -c 'echo $$ ; sleep 10000'This will print the newly created bash PID and sleep for a long time.
If I go to another terminal and do something like
ps -flax | grep leepI'll see something like
501 92418 91910 0 0:00.00 ttys000 0:00.00 bash -c echo $$... (5 Replies)
Hi, I am looking for a solution for the following problem:
Im Using tcpdump within a shellskript started in a subshell by using brackets: ( /usr/sbin/tcpdump -i ... -c 1 )
- I want the outout of tcpdump saved in a variable
- Than tcpdump-Process in the Subshell should be killed
- and I... (6 Replies)
Hi,
I am writing korn shell script. My requirement is, i have to kill the parent process and all of its child processes. Can some one please help me on this?
Thanks in advance for your help.. (1 Reply)
I have a application ID and many users in the team are using this id. I dont want the people to check whati am running with the id from my terminal. is there a way to kill history get back from my console to everybody so thatwhat ever i type in my console cant be seen from other users who are... (5 Replies)
Hello all,
I have gone through the search and looked at posting about idle users and killing processes. Here is my question I would like to kill an idle user ( which I can do) but how can I asure that all of his process is also killed whit out tracing his inital start PID. I have tried this on a... (4 Replies)