After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 524962 - g-p-m D-Bus method call always return Error when it's activated for the first time
g-p-m D-Bus method call always return Error when it's activated for the first...
Status: RESOLVED FIXED
Product: gnome-power-manager
Classification: Deprecated
Component: gnome-power-manager
2.22.x
Other All
: Normal critical
: ---
Assigned To: GNOME Power Manager Maintainer(s)
GNOME Power Manager Maintainer(s)
Depends on:
Blocks:
 
 
Reported: 2008-03-29 13:36 UTC by Xiurong Simon Zheng
Modified: 2008-12-02 09:48 UTC
See Also:
GNOME target: ---
GNOME version: 2.21/2.22


Attachments
A possible fix (383 bytes, patch)
2008-04-04 14:15 UTC, Xiurong Simon Zheng
none Details | Review
patch to remove the daemon code. (1.25 KB, patch)
2008-11-07 06:57 UTC, Wang Xin
none Details | Review

Description Xiurong Simon Zheng 2008-03-29 13:36:17 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.
Comment 1 Xiurong Simon Zheng 2008-03-29 14:00:11 UTC
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.
Comment 2 Xiurong Simon Zheng 2008-04-04 14:15:37 UTC
Created attachment 108609 [details] [review]
A possible fix

In case of activation, launch no-deamon.
Comment 3 Richard Hughes 2008-04-04 15:29:08 UTC
tbh, I think we can just rip out the daemon code from trunk. If the others don't use it, then neither should we.
Comment 4 Xiurong Simon Zheng 2008-04-04 16:26:35 UTC
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.
Comment 5 Cesare Tirabassi 2008-04-22 09:13:26 UTC
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

?
Comment 6 Wang Xin 2008-11-07 06:47:36 UTC
(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.
Comment 7 Wang Xin 2008-11-07 06:57:27 UTC
Created attachment 122168 [details] [review]
patch to remove the daemon code.
Comment 8 Richard Hughes 2008-12-02 09:07:29 UTC
Please apply, thanks.
Comment 9 Wang Xin 2008-12-02 09:48:20 UTC
Committed to both trunk and 224 branch.