Request for C API to change process name

Originator:rsesek
Number:rdar://32249963 Date Originated:2017-05-17
Status:Open Resolved:
Product:macOS + SDK Product Version:Mac OS X 10.12.5 (16F73)
Classification:Suggestion Reproducible:N/A
 
Area:
Something not on this list


Summary:
Other POSIXes have a C/kernel API to change the current process name, to differentiate it from the name by which it was launched (either p_comm or p_name in the kernel proc_t). This is useful for several situations:

- Scripting-language based programs that want to change their ps name from e.g. `python' to `server name'.
- Programs that use fork() to create a worker pool of processes, with a master parent process controlling the children, to differentiate the different processes.
- Add additional status information to the `ps` line.

Other BSDs provide this functionality via setproctitle() https://www.freebsd.org/cgi/man.cgi?query=setproctitle&sektion=3, and Linux provides it via prctl(PR_SET_NAME) http://man7.org/linux/man-pages/man2/prctl.2.html. Setting the main thread's title via pthread_setname_np() does not alter the process name, as it does on Linux.

This is a request for an API similar to setproctitle() on macOS.


Steps to Reproduce:
Want to change the process name (in the output of `ps` and Activity Monitor.app) after it is already running.


Expected Results:
An API like setproctitle() to change the process title.


Observed Results:
There is no API to change the process title after a process is running.


Version:
Mac OS X 10.12.5 (16F73)

Comments


Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!