From 58be9e0bf1e58131e4e8d2b74f41b7b8e154b4b8 Mon Sep 17 00:00:00 2001 From: John Soo Date: Wed, 4 Nov 2020 07:51:52 -0800 Subject: processes: Add '--format' and the "normalized" format. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * guix/scripts/processes.scm (lock->recutils): New procedure. (daemon-session->recutils): Use it. (daemon-sessions->recutils, session-key->recutils) (session-scalars->normalized-record) (child-process->normalized-record) (daemon-sessions->normalized-record): New procedures. (session-rec-type, lock-rec-type, child-process-rec-type) (%available-formats): New variables. (list-formats): New procedure. (%options, show-help): Add '--format'. (%default-options): New variable. (guix-processes): Use 'parse-command-line' instead of 'args-fold*'. Honor the 'format' value in OPTIONS. * doc/guix.texi (Invoking guix processes): Document '--format'. Signed-off-by: Ludovic Courtès --- doc/guix.texi | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) (limited to 'doc/guix.texi') diff --git a/doc/guix.texi b/doc/guix.texi index 7cef2371ad..e7277fc9ee 100644 --- a/doc/guix.texi +++ b/doc/guix.texi @@ -12899,6 +12899,45 @@ ClientPID: 19419 ClientCommand: cuirass --cache-directory /var/cache/cuirass @dots{} @end example +Additional options are listed below. + +@table @code +@item --format=@var{format} +@itemx -f @var{format} +Produce output in the specified @var{format}, one of: + +@table @code +@item recutils +The default option. It outputs a set of Session recutils records +that include each @code{ChildProcess} as a field. + +@item normalized +Normalize the output records into record sets (@pxref{Record Sets,,, +recutils, GNU recutils manual}). Normalizing into record sets allows +joins across record types. The example below lists the PID of each +@code{ChildProcess} and the associated PID for @code{Session} that +spawned the @code{ChildProcess} where the @code{Session} was started +using @command{guix build}. + +@example +$ guix processes --format=normalized | \ + recsel \ + -j Session \ + -t ChildProcess \ + -p Session.PID,PID \ + -e 'Session.ClientCommand ~ "guix build"' +PID: 4435 +Session_PID: 4278 + +PID: 4554 +Session_PID: 4278 + +PID: 4646 +Session_PID: 4278 +@end example +@end table +@end table + @node System Configuration @chapter System Configuration -- cgit v1.2.3