Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Yes, and on Linux I can also use the appropriate flags to `ps`, but I wish I wouldn't have to look at (potentially very cluttered) full command lines or command invocations.

It makes everything run as <interpreter> <script> just feel less "native" when dealing with processes than binary executables (or things run via binfmt_misc, which is unfortunately not very common for Java applications at least, and it seems like a mix for Python as well).



There is no API for a process to change its name. More precisely, there is no concept of a “process name”, there is only the name of the executable file (image) that was loaded.


At least on Linux, it's definitely possible with prctl(2):

    PR_SET_NAME
         Set the name of the calling thread, using the value in the
         location pointed to by name.

         The name can be up to 16 bytes long, including the
         terminating null byte.  If the length of the string,
         including the terminating null byte, exceeds 16 bytes, the
         string is silently truncated.


I was talking about Windows, given the context of TFA. You can also name threads in Windows. Especially in background applications, however, the initial main thread may not exist for the whole duration of the process (e.g. consider pthread_exit), so I’m not sure how practical that approach would be.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: