! Please note that this is a snapshot of our old Bugzilla server, which is read only since May 29, 2020. Please go to gitlab.xfce.org for our new server !
process run by genmon plugin are zombified
Status:
RESOLVED: FIXED
Product:
Xfce4-genmon-plugin
Component:
General

Comments

Description Yves-Alexis Perez editbugs 2008-02-29 13:14:29 CET
A debian user reported that process spawned by genmon plugin were zombified because it doesn't wait for termination.

Attached patch seems to fix the problem (but may have side effects too).
Comment 1 Yves-Alexis Perez editbugs 2008-02-29 13:15:20 CET
Created attachment 1532 
wait for child termination
Comment 2 Julien Devemy 2008-03-15 22:50:35 CET
I don't want to change this behaviour because the change can cause the hung of the plugin, which is (for me) worse.
Comment 3 Yves-Alexis Perez editbugs 2008-03-15 22:58:55 CET
(In reply to comment #2)
> I don't want to change this behaviour because the change can cause the hung of
> the plugin, which is (for me) worse.

Well, maybe there's another solution? Because letting zombies everywhere isn't really great either.
Comment 4 Julien Devemy 2008-03-15 23:05:54 CET
I know it's not a acceptable answer I made.

But I think it's the script responsability to finish cleanly (manage timeout or things like that).

It's surely possible to do better in the plugin, but I don't want to add too much complexity to the code.

If somebody has an idea or a patch, he's welcomed ;)

Comment 5 Yves-Alexis Perez editbugs 2008-03-15 23:14:04 CET
(In reply to comment #4)
> It's surely possible to do better in the plugin, but I don't want to add too
> much complexity to the code.
> 
> If somebody has an idea or a patch, he's welcomed ;)

I don't know how xfrun handles this, but maybe there are good ideas to pick there?
Comment 6 Mike Massonnet editbugs 2008-03-16 15:23:24 CET
A start point can be revision 26432 (see bug #2983)
Comment 7 Steve 2008-04-15 22:10:59 CEST
The plugin hangs with patch 1532 because genmon_Spawn() is waiting for I/O when there will be none.

With the patch, strace shows that genmon calls waitpid() and then hangs at poll(). Here's how to confirm.

Configure a genmon command script to call /bin/true on click and set the period to one second. (Attachment follows.)

$ ps -e | fgrep genmon
26211 ?        00:00:00 xfce4-genmon-pl
$ strace -p 26211 -f 2>x.log

x.log has these lines:
...
[pid 26360] execve("/bin/true", ["/bin/true"], [/* 40 vars */]) = 0
...
[pid 26360] exit_group(0)               = ?
Process 26360 detached
--- SIGCHLD (Child exited) @ 0 (0) ---
waitpid(26360, NULL, 0)                 = 26360
poll( <unfinished ...>
Process 26211 detached
Comment 8 Steve 2008-04-15 22:14:53 CEST
Created attachment 1590 
shell script to invoke /bin/true on clicking the genmon icon
Comment 9 Steve 2008-04-15 23:56:24 CEST
The ability to click on a genmon icon to launch a program is already implemented with the Xfce launcher plugin. That plugin detaches the launched program (parent process of launched program has process id 1) and thereby avoids waiting or hanging.

The genmon plugin is reimplementing the launcher functionality.

Skimming the Xfce panel code, I see that it uses a variety of GLib functions,
including g_spawn_sync() and g_spawn_async().
These functions are documented here:
http://library.gnome.org/devel/glib/2.16/glib-Spawning-Processes.html
Comment 10 Steve 2008-04-16 15:16:48 CEST
Created attachment 1592 
patch to call xfce_exec() instead of genmon_SpawnCmd()

With this patch there are no zombies and the child process does not hang the plugin.

libxfcegui4 has a variety of functions for execing processes.
See libxfcegui4/xfce-exec.h
Comment 11 Steve 2008-04-16 15:23:26 CEST
Created attachment 1593 
shell script to invoke sleep as a plugin command to test patch

Use this plugin to simulate a non-exiting process.
It simply invokes "sleep 3600" as the click command.

The sleep processes should all have a parent process id of 1.
ps -ef | fgrep sleep
Comment 12 Steve 2008-04-16 20:04:40 CEST
Created attachment 1594 
patch to call xfce_exec() instead of genmon_SpawnCmd(); with error handling

This adds error handling if the command cannot be found.
The error handling is adapted from:
xfce4-panel-4.4.2/plugins/launcher/launcher.c
Comment 13 Yves-Alexis Perez editbugs 2008-04-16 20:16:43 CEST
Do you consider the patch ready for production? I'm about to upload a fixed version to Debian.
Comment 14 Steve 2008-04-16 20:26:23 CEST
Created attachment 1595 
shell script to test patch by invoking various commands

# Test cases for the Xfce genmon plugin's command launcher.
# Configure the genmon plugin to invoke this shell script once per second.
# Uncomment one of the "<click>" commands
# while the plugin is running to test a particular case.
# Each test case can be selected while the plugin is running,
# because the plugin reinvokes the command each second.
Comment 15 Steve 2008-04-16 20:37:09 CEST
(In reply to comment #13)
> Do you consider the patch ready for production? I'm about to upload a fixed
> version to Debian.
> 

Yes, it is working with the test cases I have attached.
1. Commands are correctly invoked.
2. No zombies.
3. No hangs.
4. Error reporting when the command cannot be found.
Comment 16 Florian Rivoal editbugs 2011-02-24 15:22:25 CET
Applied. Thanks

Bug #3896

Reported by:
Yves-Alexis Perez
Reported on: 2008-02-29
Last modified on: 2011-02-24

People

Assignee:
Florian Rivoal
CC List:
1 user

Version

Version:
3.2 or older

Attachments

Additional information