bitbake-worker: set the process name when starting a task
RFC PATCH 1/1 bitbake-worker: set the process name when starting a task
If the setproctitle module is present then use it to change the process name when the worker starts a task. This results in each worker showing what task it is executing in a process listing.
--- bitbake/bin/bitbake-worker | 6 ++++++ 1 file changed, 6 insertions(+)
bitbake/bin/bitbake-worker +6 -0
@@ -371,6 +371,12 @@ class BitbakeWorker(object): fn, task, taskname, quieterrors, appends, taskdepdata = pickle.loads(data) workerlog_write("Handling runtask %s %s %s\n" % (task, fn, taskname)) + try: + import setproctitle + setproctitle.setproctitle("bitbake-worker: %s:%s" % (os.path.basename(fn), taskname)) + except ImportError: + pass + pid, pipein, pipeout = fork_off_task(self.cookercfg, self.data, self.workerdata, fn, task, taskname, appends, taskdepdata, quieterrors) self.build_pids[pid] = task
Signature · 1 line
2.6.4
Quoted 8 lines · Ross Burton
If the setproctitle module is present then use it to change the process name
when the worker starts a task. This results in each worker showing what task it
is executing in a process listing.Signed-off-by Ross Burton <[email protected]>
Very nice. Do you know if it's overwriting just the process name or the entire commandline? I'm wondering if pkill bitbake-worker would do what you want, or if you'd still need to use pkill -f, for example. I'd like to see the toplevel bitbake processes named nicely without the python path and whatnot too eventually. We could also name the parallel parsing processes (though admittedly they're not long lived). Perhaps this should go into a helper function in bb.utils or bb.process?
Signature · 5 lines
Christopher Larson clarson at kergoth dot com Founder - BitBake, OpenEmbedded, OpenZaurus Maintainer - Tslib Senior Software Engineer, Mentor Graphics
Quoted 10 lines · Christopher Larson
Quoted 8 lines · Ross Burton
If the setproctitle module is present then use it to change the process name
when the worker starts a task. This results in each worker showing what task it
is executing in a process listing.Signed-off-by Ross Burton <[email protected]>
Quoted 8 lines
Very nice. Do you know if it's overwriting just the process name or the entire commandline? I'm wondering if pkill bitbake-worker would do what you want, or if you'd still need to use pkill -f, for example. I'd like to see the toplevel bitbake processes named nicely without the python path and whatnot too eventually. We could also name the parallel parsing processes (though admittedly they're not long lived). Perhaps this should go into a helper function in bb.utils or bb.process?
There is a slightly more ugly version of this we could use:
def set_process_title(name):
from ctypes import cdll, byref, create_string_buffer libc = cdll.LoadLibrary('libc.so.6')
buff = create_string_buffer(len(name)+1) buff.value = name
libc.prctl(15, byref(buff), 0, 0, 0)
which would then mean we don't have a dependency on the external module. Obviously using ctypes is a bit nasty though.
I would like to see this markup the worker/cooker/UI threads and so on...
Cheers,
Richard