
I have an icon for xmms on my desktop. I click on the icon; xmms opens in its own little window. I open a terminal. I type in it kill -9 $(pidof xmms) and press Enter. The xmms window closes. I have a bash script. A line in it runs xmms, at which point xmms's little window opens and converts a .wma file to a .wav file. The next line in the script says kill -9 $(pidof xmms), but it doesn't work to close the xmms window. That window stays open until I click on the close box in the top right of the window. Why doesn't the kill command work in the second case when it works in the first?

It sounds like the script is never getting to the point of executing the kill command, because it's waiting for xmms to end and hand control back. If you close xmms manually after executing the script, you'll probably get a "no process killed" error, and then the script will end. The script code would help, of course (: Any particular reason you're using kill -9, btw? Wouldn't a normal sigterm do the job? And isn't it easier to use killall xmms, rather than funky things with kill? Regards, Bnonn On Mon, 2006-05-22 at 17:43 +1000, Leslie Katz wrote:
I have an icon for xmms on my desktop. I click on the icon; xmms opens in its own little window. I open a terminal. I type in it kill -9 $(pidof xmms) and press Enter. The xmms window closes.
I have a bash script. A line in it runs xmms, at which point xmms's little window opens and converts a .wma file to a .wav file. The next line in the script says kill -9 $(pidof xmms), but it doesn't work to close the xmms window. That window stays open until I click on the close box in the top right of the window.
Why doesn't the kill command work in the second case when it works in the first?
_______________________________________________ wlug mailing list | wlug(a)list.waikato.ac.nz Unsubscribe: http://list.waikato.ac.nz/mailman/listinfo/wlug

* Dominic Tennant <bnonn(a)orcon.net.nz> [2006-05-22 10:00]:
Any particular reason you're using kill -9, btw?
Indeed; cf. http://sial.org/howto/shell/kill-9/ and http://laku19.adsl.netsonic.fi/~era/unix/award.html#uuk9letter
Wouldn't a normal sigterm do the job? And isn't it easier to use killall xmms, rather than funky things with kill?
In this particular case, the right thing is to say `kill %%`, since `%%` refers to the last stopped or backgrounded process. This is precise and won’t go around killing random other processes that happen to have the same name as the one you want. In the case of killing xmms, there probably won’t be others, but if you get into the habit of killing processes by name in scripts you’re guaranteed to give yourself a nasty surprise someday. Regards, -- Aristotle Pagaltzis // <http://plasmasturm.org/>

Leslie Katz wrote:
I have an icon for xmms on my desktop. I click on the icon; xmms opens in its own little window. I open a terminal. I type in it kill -9 $(pidof xmms) and press Enter. The xmms window closes.
I have a bash script. A line in it runs xmms, at which point xmms's little window opens and converts a .wma file to a .wav file. The next line in the script says kill -9 $(pidof xmms), but it doesn't work to close the xmms window. That window stays open until I click on the close box in the top right of the window.
Why doesn't the kill command work in the second case when it works in the first?
At work, most of our test scripts are bash... We use, in some cases where it is safe too, "killall" (from the psmisc package): killall xmms But that has the affect of killing all (go figure ;) ) processes with that name. If that works, then sweet. If we want to only kill a specific instance of an application, we usually do: xmms & xmms_pid=$! . . . kill $xmms_pid This way works nice in most environments, "killall" isn't available for cygwin and "pidof" seems to be a debian thing (maybe RHEL too cant recall) but not for FreeBSD or cygwin. Michael

On Mon, May 22, 2006 at 09:16:04PM +1200, Michael J Knox wrote:
At work, most of our test scripts are bash...
We use, in some cases where it is safe too, "killall" (from the psmisc package):
killall xmms
But that has the affect of killing all (go figure ;) ) processes with that name. If that works, then sweet.
I hope you get the opportunity to admin a solaris box one day.... :) John

John R. McPherson wrote:
On Mon, May 22, 2006 at 09:16:04PM +1200, Michael J Knox wrote:
At work, most of our test scripts are bash...
We use, in some cases where it is safe too, "killall" (from the psmisc package):
killall xmms
But that has the affect of killing all (go figure ;) ) processes with that name. If that works, then sweet.
I hope you get the opportunity to admin a solaris box one day.... :)
Use too, HP-UX and NCR UNIX too Michael

* John R. McPherson <jrm21(a)cs.waikato.ac.nz> [2006-05-22 11:45]:
I hope you get the opportunity to admin a solaris box one day.... :)
You are evil. :) Regards, -- Aristotle Pagaltzis // <http://plasmasturm.org/>
participants (5)
-
A. Pagaltzis
-
Dominic Tennant
-
John R. McPherson
-
Leslie Katz
-
Michael J Knox