Bug 147947

Summary: beagle doesn't show itself as beagle in "top"
Product: [openSUSE] SUSE Linux 10.1 Reporter: Dirk Mueller <dmueller>
Component: GNOMEAssignee: Miguel de Icaza <miguel>
Status: RESOLVED FIXED QA Contact: E-mail List <qa-bugs>
Severity: Normal    
Priority: P5 - None CC: suse-beta
Version: Beta 3   
Target Milestone: ---   
Hardware: Other   
OS: Other   
Whiteboard:
Found By: Other Services Priority:
Business Priority: Blocker: ---
Marketing QA Status: --- IT Deployment: ---
Attachments: Zen error source properties
Zen Touch random error on plugging-in the device
Zen Touch timing out on synching libraries

Description Dirk Mueller 2006-02-03 11:12:29 UTC
this seems to be a general mono problem, not sure. beagle should set its own process name correctly via prctl(PR_SET_NAME).
Comment 1 Joe Shaw 2006-02-06 15:00:30 UTC
It is a broader mono issue, so it'll affect (at least) banshee and f-spot as well.  A temporary workaround for 10.1 might make sense, but this should probably be fixed at a lower level than beagle.  I'm adding Aaron (banshee) and Larry (f-spot) to the CC line, and reassigning to Miguel.

We're already running mono with "exec -a mono-beagled" but unfortunately "killall mono-beagled" doesn't work and it shows up as "mono" in top unless you press 'c'.

My prctl(2) manpage doesn't include PR_SET_NAME.  Do I just pass in a const char * for the name as the second argument?  Will that work with things like "killall"?  In what kernel version was PR_SET_NAME added?
Comment 2 Dirk Mueller 2006-02-06 15:23:14 UTC
yes, call it like

const char* name = "foo";
prctl(PR_SET_NAME, (unsigned long) name, 0, 0, 0);

I'm not sure when it was added. I added support for it in KDE on 2004-09-26. 

Comment 3 Aaron Bockover 2006-02-06 16:03:08 UTC
Just tested prctl in Banshee. It works great. I can "killall banshee" and it shows up as banshee in top and the gnome system monitor. Between "exec -a" and prctl, it seems almost all bases are covered. Would be best to have this in mono itself though.

[DllImport("libc")]
private static extern int prctl(int option, byte [] arg2, ulong arg3, 
    ulong arg4, ulong arg5);
        
public static void SetProcessName(string name)
{
    if(prctl(15 /* PR_SET_NAME */, Encoding.ASCII.GetBytes(name), 
        0, 0, 0) != 0) {
        throw new ApplicationException("Error setting process name: " + 
            Mono.Unix.Native.Stdlib.GetLastError());
    }
}
Comment 4 Joe Shaw 2006-02-08 18:20:57 UTC
I just checked this in for many tools in beagle to CVS.
Comment 5 Miguel de Icaza 2006-02-08 19:56:44 UTC
We looked at implementing this bit, the technical aspects are not hard (prctl is only one part of the equation, the other bit is actually setting the visible process name which is operating system specific).

But we ran into a larger issue, consider:

mono -O=all program.exe --arg1 --arg2

What should the command line become?

program.exe --arg1 --arg2

Or:

program -O=all program.exe --arg1 --arg2

I think that at this point, until we evaluate what are the pros and cons of the various options, Mono should not dictate a policy and leave it up to the applications. 
Comment 6 Aaron Bockover 2006-02-08 20:52:48 UTC
Regarding my managed snippet for using prctl:

Encoding.ASCII.GetBytes(name)

Should be

Encoding.ASCII.GetBytes(name + "\0")

A non-NUL-terminated process name may cause problems.
Comment 7 Dirk Mueller 2006-02-09 10:38:42 UTC
the command line has nothing to do with the process name. you want people to be able to do "killall beagle" to recover their system, and not "killall mono" (which kills zmd etc as well). 

Comment 8 Aaron Bockover 2006-02-09 16:29:26 UTC
That's the point of using prctl. But there are two issues here:

a) Make "killall beagle" work, which is accomplished using prctl. Joe has patched Beagle programs for this, I have patched Banshee.

b) Make the process listing more aesthetically pleasing, which is what Miguel was talking about. 

For instance:

"exec -a 'beagle' mono -O=all beagle.exe --arg1 --arg2"

Will show up in listings as:

"beagle -O=all beagle.exe --arg2 --arg3"

When ideally we only want to show:

"beagle --arg2 --arg3"

We don't have a solution for this. We can't just shift elements in the argv[] array, as they are statically allocated and may not fit:

"--play"
"--enqueue"
"file:///path/to/song.mp3"

Shifting that once would yield:

"--enqu"
"file:///p"

We'd have to create a new allocated array with shifted elements and then re-exec the program, and that complexity and overhead is probably not worth it.

Currently just using the prctl and exec -a solution for individual apps works well. killall works, and process listings are reasonably sane.
Comment 9 Martin Baulig 2006-02-10 08:39:06 UTC
I'm also interested in this feature for the debugger.
Comment 10 Joe Shaw 2006-03-06 22:34:06 UTC
beagle package which does this has been submitted.
Comment 11 Christian Jäger 2007-01-25 09:40:50 UTC
Created attachment 114922 [details]
Zen error source properties
Comment 12 Christian Jäger 2007-01-25 09:41:16 UTC
Created attachment 114923 [details]
Zen Touch random error on plugging-in the device
Comment 13 Christian Jäger 2007-01-25 09:41:38 UTC
Created attachment 114924 [details]
Zen Touch timing out on synching libraries
Comment 14 Christian Jäger 2007-01-25 09:43:10 UTC
Sorry, posted attachments to wrong bugreport; could someone with the appropriate rights please delete them?
Comment 15 Magnus Boman 2007-05-01 01:01:58 UTC
Miguel, is this being worked on?
Comment 16 Miguel de Icaza 2007-05-06 18:08:52 UTC
We do not have plans on generalizing this to Mono. 
Comment 17 JP Rosevear 2007-11-02 15:02:06 UTC
Beagle, Banshee, F-Spot all do this now.

I'll interpret #16 from miguel as a wontfix for generalizing this.

Resolved fixed for the original bug.