GNOME Bugzilla – Bug 524962
g-p-m D-Bus method call always return Error when it's activated for the first time
Last modified: 2008-12-02 09:48:20 UTC
Please describe the problem: Don't run g-p-m and let it activated by the first method call. The first method call with it always returns Error. Steps to reproduce: 1. Let g-p-m exit from session background, e.g. $pkill gnome-power 2. Send some method call message to g-p-m, $dbus-send --session --print-reply --dest=org.freedesktop.PowerManagement \ /org/freedesktop/PowerManagement \ org.freedesktop.DBus.Introspectable.Introspect or $dbus-send --session --print-reply --dest=org.freedesktop.PowerManagement \ /org/freedesktop/PowerManagement \ org.freedesktop.PowerManagement.CanSuspend Actual results: Display error message as below. "Error org.freedesktop.DBus.Error.Spawn.ChildExited: Launch helper exited with unknown return code 0" Expected results: Return correct result,such as D-Bus interface description or bool value. Does this happen every time? Yes. Other information: In fact, g-p-m is already spawned by session message bus. But it returns error to the first method caller. The latter method caller work correctly.
Try with notification-daemon, it can work properly with the first method call activation. Looking into dbus activation source, after message bus successfully spawns process for g-p-m service, it will waitpid() g-p-m process. The root case is, when g-p-m is launched, g-p-m will daemonize itself through below code. " if (no_daemon == FALSE && daemon (0, 0)) { gpm_error ("Could not daemonize: %s", g_strerror (errno)); } " daemon() always exit itself and fork a child process to run background. So message bus waitpid() got a status "CHILD_EXITED", and tell the first method caller "Launch helper exited with unknown return code 0". In fact, g-p-m daemon still run as child process. Following workaround work at my end. Change gnome-power-manager.service with no-daemon option. [D-BUS Service] Name=org.freedesktop.PowerManagement Exec=/usr/bin/gnome-power-manager --no-daemon Can we disable dameonize operation inside g-p-m? I checked gnome-session and notification-daemon, they don't have any special daemon calling, just let it launch normally. Personally I guess this's okay since g-p-m is almost launched via GNOME session autostart or D-Bus activation.
Created attachment 108609 [details] [review] A possible fix In case of activation, launch no-deamon.
tbh, I think we can just rip out the daemon code from trunk. If the others don't use it, then neither should we.
The new gnome-session D-Bus interface "org.gnome.SessionManager" is possibly a potential consumer of g-p-m service. When I test it, found this activation issue. In fact, activation rarely occurs since g-p-m is auto started when login. Removal of daemon will influence CLI. Maybe good to leave it as it now. Until it's really necessary.
Just bear with me, I'm shooting in the dark here. Could this be linked to this problem: https://bugs.launchpad.net/ubuntu/+source/gnome-session/+bug/150846 ?
(In reply to comment #5) > Just bear with me, I'm shooting in the dark here. Could this be linked to this > problem: > > https://bugs.launchpad.net/ubuntu/+source/gnome-session/+bug/150846 > > ? > The behavior of these two bugs are different. In this bug, you will not see the red Quit button at all.
Created attachment 122168 [details] [review] patch to remove the daemon code.
Please apply, thanks.
Committed to both trunk and 224 branch.