MozillaZine

Cleanly close Thunderbird from the command line?

Discussion of features in Mozilla Thunderbird
Luke276
 
Posts: 5
Joined: January 8th, 2006, 7:26 pm

Post Posted February 2nd, 2008, 10:23 pm

I often run thunderbird over ssh, remotely logging into my Ubuntu 7.10 PC. Sometimes, I'll have left Thunderbird running, and will either have to kill Thunderbird (and clean up the locks) , or just wait till I get back home. Is there a way to cleanly close all instances of Thunderbird currently running? Would a script that killed Thunderbird and removed the locks essentially do the same thing? I'm a little worried that there might be something else that isn't cleaned up properly (and of course there's always the worry Thunderbird is doing something when I kill it.)

Rod Whiteley

User avatar
 
Posts: 11480
Joined: December 6th, 2004, 3:41 am
Location: UK

Post Posted February 7th, 2008, 3:34 pm

If you simply kill it, then Thunderbird does not write some things back to disk. For example, you could lose some settings changes. But there does not seem to be a way to close it cleanly from a command line.

As an experiment, I added support for a command line -quit switch in my Mail Tweak extension. I have no idea whether it will work in your situation.
Last edited by Rod Whiteley on June 13th, 2008, 5:19 am, edited 1 time in total.
Rod

rsx11m
Moderator
 
Posts: 14423
Joined: May 3rd, 2007, 7:40 am
Location: US

Post Posted February 7th, 2008, 3:56 pm

Sending the process a SIGHUP works for me (process ID obtained from "lock" symlink), giving the same result as logging out while it is running, and also cleaning up the locks. But then, I'm using the customized RPM's from SuSE, so maybe something works differently in Ubuntu.

klades
 
Posts: 855
Joined: May 3rd, 2004, 1:20 pm

Post Posted February 8th, 2008, 3:32 am

By default "kill" command should send a "SIGTERM" signal, so the process should be terminated cleanly.
See "man kill" and "man signal" and http://en.wikipedia.org/wiki/SIGTERM

Rod Whiteley

User avatar
 
Posts: 11480
Joined: December 6th, 2004, 3:41 am
Location: UK

Post Posted February 8th, 2008, 9:12 am

I tried it on Ubuntu. SIGTERM and SIGHUP both caused settings changes to be lost, although the profile lock was cleared.
Rod

rsx11m
Moderator
 
Posts: 14423
Joined: May 3rd, 2007, 7:40 am
Location: US

Post Posted February 8th, 2008, 10:24 am

You are right, it's not updating prefs.js and some other files in the profile when closed this way. This appears to be a known issue, I found a fairly old enhancement request to be able to close Mozilla from the command line and about not updating things correctly if shut down by a signal. I would consider it rather a bug though if SIGTERM and SIGHUP are not honored in the way they should, like shutting down the application similar to normally closing it...

klades
 
Posts: 855
Joined: May 3rd, 2004, 1:20 pm

Post Posted February 26th, 2008, 4:31 am

Rod Whiteley, I think to have found a "quit" routine working.
Could you tell me which settings exactly are lost if you kill Thunderbird from the command line with SIGHUP or SIGTERM?

Rod Whiteley

User avatar
 
Posts: 11480
Joined: December 6th, 2004, 3:41 am
Location: UK

Post Posted February 26th, 2008, 5:01 am

I did not investigate fully. I think normally Thunderbird may write localstore.rdf when a window closes, and prefs.js when the application closes, but there might be others—for example, I do not know when add-ons change requests are written so that they can be completed on the next restart.

Mail Tweak looks for a window containing goQuitApplication, and calls it, but it might not always succeed:
http://lxr.mozilla.org/seamonkey/source ... rlay.js#49
Rod

klades
 
Posts: 855
Joined: May 3rd, 2004, 1:20 pm

Post Posted February 26th, 2008, 5:42 am

Hello again Rod.
Which version of Mail Tweak has this option? If it has not been released yet, could I try it?
In my test, I've tried to use "goQuitApplication" function, but I always had "zombie" processes (on Windows, no test yet on Linux). Maybe your method has fixed this problem.
It seems to work better enumerate open windows and close them with "close()" method called with setTimeout, but I must investigate more about it.

Rod Whiteley

User avatar
 
Posts: 11480
Joined: December 6th, 2004, 3:41 am
Location: UK

Post Posted February 26th, 2008, 6:42 am

I sent you a private message. I did not try to fix any problems in goQuitApplication. Enumerating windows and closing them is exactly what it does: http://lxr.mozilla.org/seamonkey/source ... up.cpp#258
Rod

klades
 
Posts: 855
Joined: May 3rd, 2004, 1:20 pm

Post Posted February 26th, 2008, 9:05 am

I tried your test version, but in Linux I get this error:

Code: Select all
The program 'thunderbird-bin' received an X Window System error.


Instead with this code, it seems to work on Linux and gives no "zombie" process on win:

Code: Select all
var ww = Components.classes["@mozilla.org/embedcomp/window-watcher;1"].
    getService(Components.interfaces.nsIWindowWatcher);
var enum = ww.getWindowEnumerator();
   while (enum.hasMoreElements()) {
      var w = enum.getNext()
   w.setTimeout("window.close()", 2000);
}


With this code, the shutdown seems to be clean.
But it should be more tested...
Ciao, Paolo

szbzhao
New Member
 
Posts: 1
Joined: December 23rd, 2017, 9:35 pm

Post Posted December 23rd, 2017, 9:45 pm

to All,

I currently use these commands to do that successfully from ssh command line:
1. DISPLAY=:0.0 xdotool search --onlyvisible --name thunderbird # it show me the window id
2. DISPLAY=:0.0 wmctrl -ic window_id

I not really sure if the command it can work reliably.

LIMPET235
Moderator

User avatar
 
Posts: 38149
Joined: October 19th, 2007, 1:53 am
Location: The South Coast of N.S.W. Oz.

Post Posted December 24th, 2017, 4:21 am

Locking due to very old age.
Ancient Amateur Astronomer
Win-7-HP/IntelĀ® DualCore-2.0GHz/500G HDD/4 Gig Ram/550Watt PSU/350WattUPS/Firefox-20.0-57.0/T-bird-2.0.0.24/SnagIt-v10.0.1/MWP-7.11.0.
RadioYachting. (Always choose the "Custom" Install.)

Return to Thunderbird Features


Who is online

Users browsing this forum: No registered users and 1 guest