Incorrect Process Name


Whilst debugging, I noticed that I could never find my application in the System Monitor… Here’s an example why:
[attachment=0]Wrong Application Process Name.png[/attachment]

The process, the Plugin Host in this case, appears under the name “Juce Message Th”… as does every other application from JUCE I’ve ran. Does the app need to be packaged in some way for the name to appear as the application’s?


I’m new to JUCE. But doesn’t that say something like “juce message thread”? Maybe take a look at Thread::setCurrentThreadName() to see if that fixes it?


Yes, in a debug build it gives each thread a name to help with debugging… Bit surprised that the OS would show a thread’s name rather than the process’s name, but you can change it with Thread::setCurrentThreadName()


the reason is that since NPTL is the default on linux, a thread is no more a process as it used to be, so the trick that used to change the process name to change the thread name is not supposed to work anymore.
The future is pthread_set_name_np, but as the name implies, it’s non-portable.
If you’re only using a single thread you can use Thread::setCurrentThreadName(), but if you’re using multiple thread, I would avoid this.


Ah, interesting - definitely understand what’s going on now…

I’m certainly using multiple threads; changing the main thread’s name was all that was needed. I’ve not run into any hiccups but will keep a look out.

Non-portable as in pthread_set_name_np is limited to Linux… and possibly other criteria?


pthread_setname_np works on linux starting with glibc 2.2 IIRC, and on MacOS X Lion (which is the 2 posix environment I care of).
It’s not in posix standard, yet, I know no posix system that does not support it.