your "solution" script has a BIG flaw, when you issue :
Code:
killall gnome-terminal
it will kill ALL the gnome-terminals you are currently running...and i dont think you would want this.
thats why i used ppid, so that only the present terminal is closed.
to make things more complex, i have to use the pppid now, ie, the pid of the command's (to find the pid) parent 's (this shell script) parent (the terminal).
so here is the final code :
Code:
#!/bin/bash
read -p "What game would you like to play?" GAME
metacity --replace &
$GAME
compiz --replace &
a=`ps -fp $$ |tail -1 | awk '{print $3}'`
b=`ps -fp $a | tail -1| awk '{print $3}'`
kill $b
exit
one more thing about your script...the exit status of your script is 1 - and this technically means that your script isnt yet perfect.
i am also keen to know what purpose does 'sleep' solve for you ??
Bookmarks