accounts-daemon does not terminate at computer shutdown

Bug #1288483 reported by i30817
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
accountsservice (Ubuntu)
New
Undecided
Unassigned

Bug Description

shutdown while testing a dbus-monitor script to work around a problem in in my java app :)
Seems like your logoff is pretty broken, a simple test java app with a jframe and a shutdown hook (only) always returns non-zero on logoff (and doesn't run the hook) and other gnome programs crash regularly there. Something is rotten in denmark
package i3.main;

import java.awt.EventQueue;
import java.io.IOException;
import java.lang.management.ManagementFactory;
import java.lang.reflect.InvocationTargetException;
import javax.swing.JFrame;
import javax.swing.WindowConstants;
import org.openide.util.Exceptions;

/**
 * Test for shutdown bug workaround
 *
 * @author i30817
 */
public class TEST implements Runnable {

    public void main(String[] blah) {
        try {
            new TEST();
        } catch (InvocationTargetException ex) {
            Exceptions.printStackTrace(ex);
        } catch (IOException ex) {
            Exceptions.printStackTrace(ex);
        }
    }

    public TEST() throws InvocationTargetException, IOException {
        //First shutdown hook of the app to be added first after the system/native ones
        Runtime.getRuntime().addShutdownHook(new Thread(new SaveRunnable()));
        EventQueue.invokeLater(this);

        //Note: does not work with the shutdown command line utility
        if ("GNOME".equals(System.getenv("XDG_CURRENT_DESKTOP"))) {
            String pid = getProcessId();
            if (pid == null) {
                return;
            }
            //alive until we kill it, or logoff ope dialog;
            //Doesn't try to run on the real real logoff confirmed event to
            //avoid the issue it is trying to solve.
            String pleaseKillmeSoftly
                    = "( dbus-monitor --profile --session "
                    + "\"type='method_call',interface='org.gnome.SessionManager.EndSessionDialog',member='Open'\" "
                    + "& echo $! >&3 ) 3>pid "//store pid
                    //dbus monitor waits until it is flushed to notice the broken pipe
                    //we definitly dont want this on shutdown! Kill it too.
                    + "| grep -m 1 --line-buffered 'Open\\|Disconnected' "
                    + "; kill -s SIGTERM " + pid + " $(<pid) 2>/dev/null";
            System.out.println(pleaseKillmeSoftly);
            try {
                final Process unixKiller = Runtime.getRuntime().exec(pleaseKillmeSoftly);
                Runtime.getRuntime().addShutdownHook(new Thread() {

                    @Override
                    public void run() {
                        unixKiller.destroy();
                    }

                });
            } catch (IOException ex) {
                //oh well
            }
        }
    }

    private static String getProcessId() {
        final String jvmName = ManagementFactory.getRuntimeMXBean().getName();
        final int index = jvmName.indexOf('@');

        if (index < 1) {
            return System.getProperty("sun.java.launcher.pid");
        }
        return jvmName.substring(0, index);
    }

    public void run() {
        final JFrame frame = new JFrame();
        frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
        frame.validate();
        frame.setVisible(true);
    }

    private static class SaveRunnable implements Runnable {

        @Override
        public void run() {
            System.out.println("OI");
        }
    }
}

ProblemType: Bug
DistroRelease: Ubuntu 14.04
Package: accountsservice 0.6.35-0ubuntu7
ProcVersionSignature: Ubuntu 3.13.0-14.34-generic 3.13.5
Uname: Linux 3.13.0-14-generic x86_64
ApportVersion: 2.13.2-0ubuntu5
Architecture: amd64
Date: Thu Mar 6 00:06:28 2014
ExecutablePath: /usr/lib/accountsservice/accounts-daemon
InstallationDate: Installed on 2014-01-17 (47 days ago)
InstallationMedia: Ubuntu-GNOME 14.04 "Trusty Tahr" - Alpha amd64 (20140117)
OmitPids: 1320 5010 5016 5003 4987 5033 5002 4975 5016 5003 4987 5033 5002
ProcCmdline: /usr/lib/accountsservice/accounts-daemon
ProcEnviron:

SourcePackage: accountsservice
Title: accounts-daemon does not terminate at computer shutdown
UpgradeStatus: No upgrade log present (probably fresh install)

Revision history for this message
i30817 (i30817) wrote :
description: updated
i30817 (i30817)
description: updated
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.