All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH][RFC] bitbake-worker: set the process name when starting a task
@ 2016-01-06 16:25 Ross Burton
  2016-01-06 21:42 ` Christopher Larson
  0 siblings, 1 reply; 3+ messages in thread
From: Ross Burton @ 2016-01-06 16:25 UTC (permalink / raw)
  To: bitbake-devel

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 <ross.burton@intel.com>
---
 bitbake/bin/bitbake-worker | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/bitbake/bin/bitbake-worker b/bitbake/bin/bitbake-worker
index 3390f63..15b0f10 100755
--- a/bitbake/bin/bitbake-worker
+++ b/bitbake/bin/bitbake-worker
@@ -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
-- 
2.6.4



^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH][RFC] bitbake-worker: set the process name when starting a task
  2016-01-06 16:25 [PATCH][RFC] bitbake-worker: set the process name when starting a task Ross Burton
@ 2016-01-06 21:42 ` Christopher Larson
  2016-01-07 14:00   ` Richard Purdie
  0 siblings, 1 reply; 3+ messages in thread
From: Christopher Larson @ 2016-01-06 21:42 UTC (permalink / raw)
  To: Ross Burton; +Cc: bitbake-devel@lists.openembedded.org

[-- Attachment #1: Type: text/plain, Size: 1002 bytes --]

On Wed, Jan 6, 2016 at 9:25 AM, Ross Burton <ross.burton@intel.com> wrote:

> 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 <ross.burton@intel.com>
>

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?
-- 
Christopher Larson
clarson at kergoth dot com
Founder - BitBake, OpenEmbedded, OpenZaurus
Maintainer - Tslib
Senior Software Engineer, Mentor Graphics

[-- Attachment #2: Type: text/html, Size: 1486 bytes --]

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH][RFC] bitbake-worker: set the process name when starting a task
  2016-01-06 21:42 ` Christopher Larson
@ 2016-01-07 14:00   ` Richard Purdie
  0 siblings, 0 replies; 3+ messages in thread
From: Richard Purdie @ 2016-01-07 14:00 UTC (permalink / raw)
  To: Christopher Larson, Ross Burton; +Cc: bitbake-devel@lists.openembedded.org

On Wed, 2016-01-06 at 14:42 -0700, Christopher Larson wrote:
> On Wed, Jan 6, 2016 at 9:25 AM, Ross Burton <ross.burton@intel.com>
> wrote:
> > 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 <ross.burton@intel.com>
> > 
> 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


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2016-01-07 14:00 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-01-06 16:25 [PATCH][RFC] bitbake-worker: set the process name when starting a task Ross Burton
2016-01-06 21:42 ` Christopher Larson
2016-01-07 14:00   ` Richard Purdie

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.