LinuxQuestions.org
Visit Jeremy's Blog.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices

Reply
 
Search this Thread
Old 05-10-2006, 06:36 AM   #1
zymos
Member
 
Registered: Mar 2005
Posts: 38

Rep: Reputation: 15
making a smarter shut down scripts


Hello
i have been working on a shutdown script,
http://www.happytrees.org/main/main-...bit/bed_pl.txt,
but i want the script to send a 'warning' kill signal to all programs, a minute before shutdown. The idea is, if I have a document open and unsaved in openoffice, it would cause office to ask is i wanted to save before exiting

Also i would want it to close prograns properly, so there is no file damage.

I can figure out the right kill signals

man kill: kill signals
<pre>
TERM 15 exit
USR1 exit
USR2 exit
VTALRM exit
STKFLT exit may not be implemented
PWR ignore may exit on some systems
WINCH ignore
CHLD ignore
URG ignore
TSTP stop may interact with the shell
TTIN stop may interact with the shell
TTOU stop may interact with the shell
STOP stop this signal may not be blocked
CONT restart continue if stopped, otherwise ignore
ABRT 6 core
FPE 8 core
ILL 4 core
QUIT 3 core
SEGV 11 core
TRAP 5 core
SYS core may not be implemented
EMT core may not be implemented
BUS core core dump may fail
XCPU core core dump may fail
XFSZ core core dump may fail
</pre>

thanks,
Jeff
http://en.howto.wikia.com/wiki/Main_Page

Last edited by zymos; 05-10-2006 at 06:41 AM.
 
Old 05-10-2006, 07:22 AM   #2
ioerror
Member
 
Registered: Sep 2005
Location: Old Blighty
Distribution: Slackware, NetBSD
Posts: 536

Rep: Reputation: 30
Quote:
but i want the script to send a 'warning' kill signal to all programs, a minute before shutdown. The idea is, if I have a document open and unsaved in openoffice, it would cause office to ask is i wanted to save before exiting
How would that work exactly? Unless openoffice has this functionality built in, then it's not going to work. Programs cannot magically respond to signals any way you like. USR1 and USR2 are "user" signals, you might be able to configure openoffice to respond to those, or you might not. It's application dependent.

Quote:
Also i would want it to close prograns properly, so there is no file damage.
Programs will generally exit cleanly when they receive a SIGTERM. They might or might not save unmodified work. You might be able to configure them to auto-save, you might not. What you are asking is completely application depedent. There is no globally applicable behaviour. Why don't you just save your work and close your apps before shutting down? You lazy or what?

Last edited by ioerror; 05-10-2006 at 10:11 AM. Reason: typos, forgot how to spell dependent!!
 
Old 05-10-2006, 12:22 PM   #3
zymos
Member
 
Registered: Mar 2005
Posts: 38

Original Poster
Rep: Reputation: 15
window manager kill signal

I was under the impresion that my window manager, icewm, sent a kill signal to my program when i click the [x] to close. I can also right-click 'close' on my taskbar or use my window list and click close. These all result in ''the document xxxxx has been modified, do you wish to save, for OOfice. This should also occur in Seamonkey with unfinish email drafts, etc......

am i wrong?
Jeff

http://en.howto.wikia.com/wiki/Main_Page
 
Old 05-10-2006, 12:37 PM   #4
demian
Member
 
Registered: Apr 2001
Location: Bremen, Germany
Distribution: Debian
Posts: 303

Rep: Reputation: 30
Quote:
Originally Posted by zymos
I was under the impresion that my window manager, icewm, sent a kill signal to my program when i click the [x] to close.
I believe this is implemented through Extended Window Manager Hints. A command line tool to the EMWH calls is wmctrl. You could
for instance do something like this to find the OpenOffice.org windows and ask them to gracefully quit:

wmctrl -l|grep OpenOffice.org|cut -d' ' -f 1|xargs wmctrl -i -c
 
Old 05-10-2006, 01:00 PM   #5
ioerror
Member
 
Registered: Sep 2005
Location: Old Blighty
Distribution: Slackware, NetBSD
Posts: 536

Rep: Reputation: 30
Quote:
I was under the impresion that my window manager, icewm, sent a kill signal to my program when i click the [x] to close.
No, as demian says, this is done via window manager hints. The wm sends a WM_DELETE_WINDOW client message to the app. This has nothing to do with the system signals.

Last edited by ioerror; 05-10-2006 at 01:03 PM.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
knoppix is smarter than i am soylentgreen Slackware 14 08-05-2005 01:35 PM
Making shell scripts interactive using dialog saurabh142857 Programming 2 01-03-2005 11:14 AM
Need help w/ making DNS entries w/ scripts imsam Linux - Networking 1 10-27-2004 08:09 AM
Simple scripts for making isos and burning them on cd! jlturbos Linux - General 3 02-27-2004 06:52 AM
Making desktop shortcuts to scripts? lokis_trickster Slackware 5 01-15-2004 01:12 PM


All times are GMT -5. The time now is 07:33 AM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration