You are not logged in.

#1 2008-01-05 04:19:04

peets
Member
From: Montreal
Registered: 2007-01-11
Posts: 936
Website

Shutdown from within X

I haven't been able to phrase this for google, so I'm humbly asking for human assistance --maybe yours.

I'd like to be able to shutdown/halt/poweroff my system by issuing a command while I still have applications running in an X server. If I call 'poweroff', X shuts down immediately without leaving time for its clients to shut down tidily.

I'd like to do something like this:
* Send SIGTERM to processes running inside X. Wait a while, then send SIGKILL
* Issue the 'poweroff' command.

I could put that in my ~/.xinitrc file:

xbindkeys
pekwm
# kill processes here
poweroff

I have a few questions though:
1. Is there a simpler/better method?
2. How do I find out which processes are running, which ones I own, and which ones correspond to X clients?
3. Is SIGTERM the right signal to send?

Edit: sorry for early posting. Where Google fails, man often succeeds. I'm in the middle of reading 'man proc'.

Last edited by peets (2008-01-05 04:32:33)

Offline

#2 2008-01-05 05:22:44

theringmaster
Member
From: Air Force
Registered: 2007-07-16
Posts: 581
Website

Re: Shutdown from within X

peets wrote:

I haven't been able to phrase this for google, so I'm humbly asking for human assistance --maybe yours.

I'd like to be able to shutdown/halt/poweroff my system by issuing a command while I still have applications running in an X server. If I call 'poweroff', X shuts down immediately without leaving time for its clients to shut down tidily.

I'd like to do something like this:
* Send SIGTERM to processes running inside X. Wait a while, then send SIGKILL
* Issue the 'poweroff' command.

I could put that in my ~/.xinitrc file:

xbindkeys
pekwm
# kill processes here
poweroff

I have a few questions though:
1. Is there a simpler/better method?
2. How do I find out which processes are running, which ones I own, and which ones correspond to X clients?
3. Is SIGTERM the right signal to send?

Edit: sorry for early posting. Where Google fails, man often succeeds. I'm in the middle of reading 'man proc'.

as root, Issue the 'halt' command. That does a clean shutdown.


Check me out on twitter!!! twitter.com/The_Ringmaster

Offline

#3 2008-01-05 20:28:03

peets
Member
From: Montreal
Registered: 2007-01-11
Posts: 936
Website

Re: Shutdown from within X

I think the main problem is that SIGTERM is not the right signal to send in all cases. For example, if I send a SIGTERM to firefox ('kill -s SIGTERM ####'), upon restarting it I get told that my "session closed unexpectedly". When I use my WM's close button, this doesn't happen. I wonder how my WM does this. I will go read a bit of code.

Offline

Board footer

Powered by FluxBB