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 101351 - gnome process have init as their parent
gnome process have init as their parent
Status: RESOLVED FIXED
Product: gnome-session
Classification: Core
Component: gnome-session
unspecified
Other Linux
: Normal normal
: ---
Assigned To: Session Maintainers
Session Maintainers
Depends on:
Blocks:
 
 
Reported: 2002-12-16 15:00 UTC by Karl H. Beckers
Modified: 2006-11-14 19:27 UTC
See Also:
GNOME target: ---
GNOME version: 2.9/2.10


Attachments
patch to change child execing (10.72 KB, patch)
2006-09-30 03:53 UTC, Tom Tromey
none Details | Review
updated patch (10.97 KB, patch)
2006-10-02 17:40 UTC, Tom Tromey
none Details | Review
patch to update comments (11.01 KB, patch)
2006-10-08 16:28 UTC, Tom Tromey
none Details | Review
updated to handle all async execs (13.08 KB, patch)
2006-10-22 18:57 UTC, Tom Tromey
committed Details | Review

Description Karl H. Beckers 2002-12-16 15:00:19 UTC
Description of Problem:
When logging into a Gnome session processes
started subsequently have init as their parent
process. 
(dunno if this can be regarded as a "works as
designed", but it is (a) ugly and (b) looks like
some process forked off of gnome-session and in
turn starting all the other stuff dies unexpectedly)


Steps to reproduce the problem:
1. Log in as any user ... even with a fresh home
directory
2. do a ps -ef | grep <username>

Actual Results:

<username>@ono-sendai:~$ more ps.txt 
<username>    951   661  1 13:31 ?        00:00:00
gnome-session
<username>    960   951  0 13:31 ?        00:00:00
/usr/bin/ssh-agent -- /usr/local
/garnome/etc/gdm/gnomerc
<username>    963     1  1 13:31 ?        00:00:00
/usr/local/garnome/libexec/gconf
d-2 11
<username>    969     1  0 13:31 ?        00:00:00
/usr/local/garnome/bin/esd -term
inate -nobeeps -as 2 -spawnfd 13
<username>    971     1  1 13:31 ?        00:00:00
/usr/local/garnome/libexec/bonob
o-activation-server --ac-activate --ior-output-fd=15
<username>    973     1  0 13:31 ?        00:00:00
gnome-smproxy --sm-config-prefix
 /.gnome-smproxy-W4BMIR/ --sm-client-id
117f000001000103420229700000006060000
<username>    975     1  2 13:31 ?        00:00:00
gnome-settings-daemon --oaf-acti
vate-iid=OAFIID:GNOME_SettingsDaemon --oaf-ior-fd=12
<username>    978     1  0 13:31 ?        00:00:00
xscreensaver -nosplash
<username>    981     1  2 13:31 ?        00:00:00
metacity --sm-save-file 10393431
31-687-3306172470.ms
<username>    983     1  7 13:31 ?        00:00:01
nautilus --sm-config-prefix /nau
tilus-64O0gK/ --sm-client-id
117f000001000103420229900000006060003 --no-default-
window
kb87850    985     1  3 13:31 ?        00:00:00
gnome-panel --sm-config-prefix /
gnome-panel-kfSx1N/ --sm-client-id
117f000001000103420229900000006060002 --profi
le default
<username>    987     1  0 13:31 ?        00:00:00
/usr/bin/wmtuxtime -geometry 0x0+0+678
<username>    990   983  0 13:31 ?        00:00:00
nautilus --sm-config-prefix /nautilus-64O0gK/
--sm-client-id
117f000001000103420229900000006060003
--no-default-window
<username>    991   990  0 13:31 ?        00:00:00
nautilus --sm-config-prefix /nautilus-64O0gK/
--sm-client-id
117f000001000103420229900000006060003
--no-default-window
<username>    992   990  0 13:31 ?        00:00:00
nautilus --sm-config-prefix /nautilus-64O0gK/
--sm-client-id
117f000001000103420229900000006060003
--no-default-window
<username>    996   990  0 13:31 ?        00:00:00
nautilus --sm-config-prefix /nautilus-64O0gK/
--sm-client-id
117f000001000103420229900000006060003
--no-default-window
<username>    997   990  0 13:31 ?        00:00:00
nautilus --sm-config-prefix /nautilus-64O0gK/
--sm-client-id
117f000001000103420229900000006060003
--no-default-window
<username>    998   990  0 13:31 ?        00:00:00
nautilus --sm-config-prefix /nautilus-64O0gK/
--sm-client-id
117f000001000103420229900000006060003
--no-default-window
<username>    999   990  0 13:31 ?        00:00:00
nautilus --sm-config-prefix /nautilus-64O0gK/
--sm-client-id
117f000001000103420229900000006060003
--no-default-window
<username>   1000   990  0 13:31 ?        00:00:00
nautilus --sm-config-prefix /nautilus-64O0gK/
--sm-client-id
117f000001000103420229900000006060003
--no-default-window
<username>   1001   990  0 13:31 ?        00:00:00
nautilus --sm-config-prefix /nautilus-64O0gK/
--sm-client-id
117f000001000103420229900000006060003
--no-default-window
<username>   1003     1  1 13:31 ?        00:00:00
/usr/local/garnome/libexec/battstat-applet-2
--oaf-activate-iid=OAFIID:GNOME_BattstatApplet_Factory
--oaf-ior-fd=18
<username>   1005     1  1 13:31 ?        00:00:00
/usr/local/garnome/libexec/mixer_applet2
--oaf-activate-iid=OAFIID:GNOME_MixerApplet_Factory
--oaf-ior-fd=20
root      1011  1010  0 13:32 ?        00:00:00
/bin/sh /etc/auto.home <username>
root      1014   656  0 13:32 tty2     00:00:00
grep <username>

Expected Results:

all above processes with ppid == 1 to be children
of gnome-session, or some other process started by
gnome-session

How often does this happen? 

always

Additional Information:

This is on Debian 3.0 stable with a Garnome build
of Gnome 2.0.3.

Came across this when trying to track down hangs
of mozilla ... again: don't know if this is what
you'd expect from a good knowledge of the source.
Tried to find out what would be a candidate for a
crashed process, but didn't find anything obvious
to me.

I have an strace of gnome-session where the direct
child of the inital process has lots of this?!?

4344  fcntl64(6, F_SETFD, FD_CLOEXEC)   = -1 EBADF
(Bad file descriptor)
4344  fcntl64(7, F_SETFD, FD_CLOEXEC)   = -1 EBADF
(Bad file descriptor)
4344  fcntl64(8, F_SETFD, FD_CLOEXEC)   = -1 EBADF
(Bad file descriptor)
4344  fcntl64(9, F_SETFD, FD_CLOEXEC)   = -1 EBADF
(Bad file descriptor)
4344  fcntl64(10, F_SETFD, FD_CLOEXEC)  = -1 EBADF
(Bad file descriptor)
4344  fcntl64(11, F_SETFD, FD_CLOEXEC)  = -1 EBADF
(Bad file descriptor)

also this gotten with GSM_VERBOSE_DEBUG:

<username>@ono-sendai:~$ more gsm_verbose_debug.txt 

** (process:1855): WARNING **: CORBA_ORB_destroy:
ORB still has 2 refs.

** (process:1855): WARNING **: ORB: a total of 6
refs to 5 ORB objects were leaked
gsm verbose: Adding listener for 0x806a710
SESSION_MANAGER=local/ono-sendai:/tmp/.ICE-unix/1853
gsm verbose: gsm_gsd_start(): startingLoaded
background '0x80c0120
gsm verbose: Accepting a connection...
gsm verbose: ice_watch():	connection: 0x80bb830
opening: 1
gsm verbose: Removing listener for 0x806a710
gsm verbose: iterate...
gsm verbose: activate_cb(): object: 0x80bcce8gsm
verbose: Adding listener for 0x806a710
gsm verbose: Removing listener for 0x806a710
gsm verbose: iterate...
gsm verbose: Adding listener for 0x806a710
gsm verbose: Removing listener for 0x806a710
gsm verbose: iterate...
gsm verbose: Adding listener for 0x806a710
gsm verbose: Done.
gsm verbose: new_client(): connection 0x8106fe0
gsm verbose: setting clean up handler for
connection 0x80bb830
gsm verbose: register_client: 0x8106fe0
gsm verbose: free_client(): 0x8091d28
(117f000001000103420229700000006060000)
gsm verbose: Accepting a connection...
gsm verbose: ice_watch():	connection: 0x81144a0
opening: 1
gsm verbose: Removing listener for 0x806a710
gsm verbose: iterate...
gsm verbose: Adding listener for 0x806a710
gsm verbose: Removing listener for 0x806a710
gsm verbose: iterate...
gsm verbose: Adding listener for 0x806a710
gsm verbose: Removing listener for 0x806a710
gsm verbose: iterate...
gsm verbose: Adding listener for 0x806a710
gsm verbose: Done.
gsm verbose: new_client(): connection 0x8114ea8
gsm verbose: setting clean up handler for
connection 0x81144a0
gsm verbose: register_client: 0x8114ea8
gsm verbose: free_client(): 0x8092480
(117f000001000103420229800000006060001)
gsm verbose: set_properties: 0x8114ea8
gsm verbose: Accepting a connection...
gsm verbose: ice_watch():	connection: 0x8092570
opening: 1
gsm verbose: Removing listener for 0x806a710
gsm verbose: iterate...
gsm verbose: Adding listener for 0x806a710
gsm verbose: Removing listener for 0x806a710
gsm verbose: iterate...
gsm verbose: Adding listener for 0x806a710
gsm verbose: Removing listener for 0x806a710
gsm verbose: iterate...
gsm verbose: Adding listener for 0x806a710
gsm verbose: Done.
gsm verbose: new_client(): connection 0x810fd18
gsm verbose: setting clean up handler for
connection 0x8092570
gsm verbose: register_client: 0x810fd18
gsm verbose: save_yourself_request: 0x810fd18
Window manager warning: Broken client! Window
0x40000e (xterm) changed client leader window or
SM client ID
gsm verbose: Accepting a connection...
gsm verbose: ice_watch():	connection: 0x810f310
opening: 1
gsm verbose: Removing listener for 0x806a710
gsm verbose: iterate...
gsm verbose: Adding listener for 0x806a710
gsm verbose: Removing listener for 0x806a710
gsm verbose: iterate...
gsm verbose: Adding listener for 0x806a710
gsm verbose: Removing listener for 0x806a710
gsm verbose: iterate...
gsm verbose: Adding listener for 0x806a710
gsm verbose: Done.
gsm verbose: new_client(): connection 0x811e3a8
gsm verbose: setting clean up handler for
connection 0x810f310
gsm verbose: register_client: 0x811e3a8
gsm verbose: free_client(): 0x80911c0
(117f000001000103420229900000006060002)
gsm verbose: set_properties: 0x811e3a8
gsm verbose: set_properties: 0x811e3a8
gsm verbose: set_properties: 0x811e3a8
gsm verbose: set_properties: 0x811e3a8
gsm verbose: set_properties: 0x811e3a8
gsm verbose: set_properties: 0x811e3a8
gsm verbose: Accepting a connection...
gsm verbose: ice_watch():	connection: 0x811e8d0
opening: 1
gsm verbose: Removing listener for 0x806a710
gsm verbose: iterate...
gsm verbose: Adding listener for 0x806a710
gsm verbose: Removing listener for 0x806a710
gsm verbose: iterate...
gsm verbose: Adding listener for 0x806a710
gsm verbose: Removing listener for 0x806a710
gsm verbose: iterate...
gsm verbose: Adding listener for 0x806a710
gsm verbose: Done.
gsm verbose: set_properties: 0x811e3a8
gsm verbose: set_properties: 0x811e3a8
gsm verbose: set_properties: 0x811e3a8
gsm verbose: new_client(): connection 0x8104950
gsm verbose: setting clean up handler for
connection 0x811e8d0
gsm verbose: register_client: 0x8104950
gsm verbose: free_client(): 0x8090b88
(117f000001000103420229900000006060003)
wmtuxtime: process 3038 appears to have died,
continuing
gsm verbose: set_properties: 0x8104950
gsm verbose: set_properties: 0x8104950
gsm verbose: set_properties: 0x8104950
gsm verbose: set_properties: 0x8104950
gsm verbose: set_properties: 0x8104950
gsm verbose: set_properties: 0x8104950

** (gnome-panel:1873): WARNING **: Unable to load
panel stock icon 'go'

----- RELOADING FOLDER: Root -----
----- RELOADING FOLDER: Applications -----
----- RELOADING FOLDER: Accessories -----
----- RELOADING FOLDER: Other -----
----- RELOADING FOLDER: Programming -----
----- RELOADING FOLDER: Games -----
----- RELOADING FOLDER: Graphics -----
----- RELOADING FOLDER: Internet -----
----- RELOADING FOLDER: Multimedia -----
----- RELOADING FOLDER: Office -----
----- RELOADING FOLDER: Preferences -----
----- RELOADING FOLDER: Preferences -----
----- RELOADING FOLDER: Advanced -----
----- RELOADING FOLDER: System -----
----- RELOADING FOLDER: Accessibility -----
EXTERNALLY WATCHING: preferences-all-users:///
----- RELOADING FOLDER: Advanced -----
----- RELOADING FOLDER: Sawfish -----
EXTERNALLY WATCHING: preferences-all-users:///Advanced
----- RELOADING FOLDER: Accessibility -----
EXTERNALLY WATCHING:
preferences-all-users:///Accessibility
----- RELOADING FOLDER: System -----
EXTERNALLY WATCHING: applications-all-users:///
----- RELOADING FOLDER: Programming -----
EXTERNALLY WATCHING:
applications-all-users:///Programming
----- RELOADING FOLDER: Accessories -----
EXTERNALLY WATCHING:
applications-all-users:///Accessories
----- RELOADING FOLDER: Multimedia -----
EXTERNALLY WATCHING:
applications-all-users:///Multimedia
----- RELOADING FOLDER: Other -----
EXTERNALLY WATCHING: applications-all-users:///Other
----- RELOADING FOLDER: Games -----
EXTERNALLY WATCHING: applications-all-users:///Games
----- RELOADING FOLDER: Preferences -----
----- RELOADING FOLDER: Root -----
EXTERNALLY WATCHING: preferences-all-users:///
EXTERNALLY WATCHING: preferences:///
----- RELOADING FOLDER: Advanced -----
----- RELOADING FOLDER: Advanced -----
EXTERNALLY WATCHING: preferences-all-users:///Advanced
EXTERNALLY WATCHING: preferences:///Advanced
----- RELOADING FOLDER: Accessibility -----
----- RELOADING FOLDER: Accessibility -----
EXTERNALLY WATCHING:
preferences-all-users:///Accessibility
EXTERNALLY WATCHING: preferences:///Accessibility
----- RELOADING FOLDER: Graphics -----
EXTERNALLY WATCHING:
applications-all-users:///Graphics
----- RELOADING FOLDER: System -----
EXTERNALLY WATCHING: applications-all-users:///System
----- RELOADING FOLDER: Office -----
EXTERNALLY WATCHING: applications-all-users:///Office
----- RELOADING FOLDER: StarOffice 6.0 -----
----- RELOADING FOLDER: Internet -----
EXTERNALLY WATCHING:
applications-all-users:///Internet
gsm verbose: set_properties: 0x8104950
gsm verbose: set_properties: 0x8104950
gsm verbose: process_save_request(): client 0x810fd88
gsm verbose: 	type: 1	shutting down: 0	interact: 0
	fast: 0	global: 0
gsm verbose: set_properties: 0x810fd18
gsm verbose: set_properties: 0x810fd18
gsm verbose: save_yourself_done: 0x810fd18
gsm verbose: set_properties: 0x810fd18
Comment 1 Karl H. Beckers 2002-12-16 15:08:15 UTC
Ah, btw. this was also mentioned in Bug # 60697
Comment 2 Tom Tromey 2006-09-27 01:06:36 UTC
This happens because gnome_execute_async_with_env fork()s twice.
The child simply exits and the grandchild execs the new program.
I believe this happens so that gnome programs using this API don't
have to worry about reaping children... gnome-session doesn't seem
to have any code to do this.

One way to fix this would be to make a new exec API that does not
double fork (say, via a flag -- gross).  Then, gnome-session would
have to be updated to reap children properly.

Comment 3 Tom Tromey 2006-09-29 02:04:31 UTC
I looked into this a bit more.
glib has a g_spawn API which will suit this use perfectly.
I think we can g_spawn_async the child process and then
registering a GChildWatch source to reap children.
Comment 4 Tom Tromey 2006-09-29 23:33:28 UTC
FYI - I am testing a patch for this.
Comment 5 Tom Tromey 2006-09-30 03:53:37 UTC
Created attachment 73687 [details] [review]
patch to change child execing
Comment 6 Tom Tromey 2006-10-02 17:40:31 UTC
Created attachment 73874 [details] [review]
updated patch

A minor update -- this patch now initializes the 'GError*' to NULL
in run_command_prop.
Comment 7 Vincent Untz 2006-10-08 14:14:08 UTC
Some comments:

 + why do we need to reap the child ourselves? Isn't it possible to let glib handle this?

 + I can't help with your new FIXME :-)

 + we lost a TODO, which isn't fixed. Can you put it back?

Looks okay otherwise. Were you able to test the patch?
Comment 8 Tom Tromey 2006-10-08 16:27:25 UTC
> why do we need to reap the child ourselves?

Do you mean, why are we using G_SPAWN_DO_NOT_REAP_CHILD?
Without this flag, glib's spawn API fork()s twice to avoid reaping issues.
But this is precisely what makes the new process have a parent of init.

Or do you mean, why do we register a child watcher?
I think that is just what glib makes us do.


> I can't help with your new FIXME :-)

Yeah, that's more of a note to myself.  You can remove it if you want.
I just found that code to be pretty weird.


> we lost a TODO, which isn't fixed. Can you put it back?

Ok.  That original TODO is in the wrong place, afaics.  We could not
detect whether the rstartd failed there.  We *could* detect
whether the rsh command failed to exec -- and in fact, we now do this.
In particular I think the proposed plan in that TODO comment can't work
for the purpose laid out in the comment.


> Were you able to test the patch?

Yes.
Comment 9 Tom Tromey 2006-10-08 16:28:01 UTC
Created attachment 74299 [details] [review]
patch to update comments
Comment 10 Tom Tromey 2006-10-22 18:57:21 UTC
Created attachment 75212 [details] [review]
updated to handle all async execs

This updated patch catches a couple async execs I missed earlier.
It also moves the child reaping closer to the exec -- a bit more
maintainable IMO.  Note that synchronous execs don't matter, so
I haven't touched those.
Comment 11 Vincent Untz 2006-11-14 19:27:14 UTC
I moved the exec functions to util.h and committed.