Sponsored Content
Top Forums Shell Programming and Scripting Funny : why can't I kill my parent terminal in a script ? Post 302475118 by xib.be on Friday 26th of November 2010 01:05:54 PM
Old 11-26-2010
Hi thank you both of you for your advices Smilie

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"
Code:
#!/bin/bash
($@&)
#kill  $PPID #--> KO cause this is the bash pid and not the "xterm" pid
pppid=`ps -p $PPID -o ppid=`
kill $pppid

then you can launch any program from your terminal wihtout having to close your terminal window manually Smilie
for example:
Code:
$ ./launch-and-kill-terminal-window xclock

et voilą Smilie
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
Code:
#!/bin/bash

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

Last edited by xib.be; 11-26-2010 at 02:14 PM..
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

kill parent and child

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)
Discussion started by: larry
4 Replies

2. Shell Programming and Scripting

How to kill history from terminal to others using same id

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)
Discussion started by: dsravan
5 Replies

3. UNIX for Dummies Questions & Answers

Need help to kill parent and all of its sub processes

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)
Discussion started by: Sheethal
1 Replies

4. Shell Programming and Scripting

Kill a process from parent shell within a shell script

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)
Discussion started by: 2retti
6 Replies

5. UNIX for Dummies Questions & Answers

Kill child processes, when parent is "bash"

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)
Discussion started by: teras
5 Replies

6. Shell Programming and Scripting

shell script to kill process with respect to terminal

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)
Discussion started by: asak
3 Replies

7. Shell Programming and Scripting

forking a child process and kill its parent to show that child process has init() as its parent

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)
Discussion started by: vizz_k
2 Replies

8. Shell Programming and Scripting

Kill Parent/ Child processes

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)
Discussion started by: venky338
4 Replies

9. Shell Programming and Scripting

Kill specific terminal using shell/bash

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)
Discussion started by: kamil-mech
0 Replies

10. Shell Programming and Scripting

System should not kill the child process when parent id is 1

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)
Discussion started by: vpesh
1 Replies
gnome-wm(1)							   User Commands						       gnome-wm(1)

NAME
gnome-wm - launch the GNOME window manager SYNOPSIS
gnome-wm [--default-wm wm] [--sm-client-id id] DESCRIPTION
gnome-wm is a shell script which launches the GNOME window manager, metacity. The user may specify that another window manager should be launched, either by using the --default-wm option or by setting the WINDOW_MANAGER environment variable. OPTIONS
The following options are supported: --default-wm wm Launch the window manager wm. --sm-client-id id Specify the session management ID with which the window manager should be launched. EXAMPLES
Example 1: Launching the dtwm window manager using --default-wm example% gnome-wm --default-wm dtwm Example 2: Launching the dtwm window manager using WINDOW_MANAGER example% WINDOW_MANAGER=dtwm gnome-wm ENVIRONMENT VARIABLES
See environ(5) for descriptions of the following environment variables that affect the execution of gnome-wm: NLSPATH. WINDOW_MANAGER Used to override the configured window manager to use. EXIT STATUS
The following exit values are returned: 0 Application exited successfully >0 Application exited with failure FILES
The following files are used by this application: /usr/bin/gnome-wm Executable for GNOME window manager ATTRIBUTES
See attributes(5) for descriptions of the following attributes: +-----------------------------+-----------------------------+ | ATTRIBUTE TYPE | ATTRIBUTE VALUE | +-----------------------------+-----------------------------+ |Availability |SUNWgnome-session | +-----------------------------+-----------------------------+ |Interface stability |Volatile | +-----------------------------+-----------------------------+ SEE ALSO
metacity(1), gnome-session(1), attributes(5), environ(5) NOTES
Written by Mark McLoughlin, Sun Microsystems Inc., 2003. SunOS 5.11 9 Jan 2003 gnome-wm(1)
All times are GMT -4. The time now is 08:05 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy