]> git.ipfire.org Git - thirdparty/openembedded/openembedded-core-contrib.git/commitdiff
utils: Add ability to change the process name
authorRichard Purdie <richard.purdie@linuxfoundation.org>
Fri, 29 Jan 2016 11:07:02 +0000 (11:07 +0000)
committerRichard Purdie <richard.purdie@linuxfoundation.org>
Fri, 29 Jan 2016 17:06:16 +0000 (17:06 +0000)
Being able to tell the bitbake processes apart is useful for debugging.
Add a helper function which allows this without making it a hard
dependency. Errors are ignored, this is just nice to have.

Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
lib/bb/utils.py

index 9a3efb25deb98e640caf3f404b56487109584b35..ae10213ed721d8f04d4abd7466912ad78e330593 100644 (file)
@@ -1395,3 +1395,14 @@ def ioprio_set(who, cls, value):
             raise ValueError("Unable to set ioprio, syscall returned %s" % rc)
     else:
         bb.warn("Unable to set IO Prio for arch %s" % _unamearch)
+
+def set_process_name(name):
+    from ctypes import cdll, byref, create_string_buffer
+    # This is nice to have for debugging, not essential
+    try:
+        libc = cdll.LoadLibrary('libc.so.6')
+        buff = create_string_buffer(len(name)+1)
+        buff.value = name
+        libc.prctl(15, byref(buff), 0, 0, 0)
+    except:
+        pass