[PATCH] processes: Optionally normalize recutils output.

  • Done
  • quality assurance status badge
Details
2 participants
  • John Soo
  • Ludovic Courtès
Owner
unassigned
Submitted by
John Soo
Severity
normal
J
J
John Soo wrote on 5 Nov 2020 05:31
(address . guix-patches@gnu.org)
87o8kcv30a.fsf@asu.edu
Hi Guix,

Please let me know if there is already a way to do what I want without
this patch :). I really don't know a whole lot of recutils beyond what I
learned this morning.

I was trying to extract PIDs of the child processes of sessions from the
output of guix processes. I ran into the following problem: the PID and
the command are on the same line.

---- Begin ----
$ guix processes
SessionPID: 4278
ClientPID: 4268
ClientCommand: /gnu/store/...
ChildProcess: 4435: /gnu/store/...
ChildProcess: 4554: /gnu/store/...
ChildProcess: 4646: guile --no-auto-compile ...
---- End ----

I ended up having to use sed to remove the trailing command for the
child process. After reading the documentation for recutils I found out
that records can also be expressed in separate record sets that can be
joined together.

This patch adds a --normalize flag that specifies the
recutils output be put in separate record sets for Locks, Sessions, and
ChildProcesses. For example:

---- Begin ----
PAGER=cat ./pre-inst-env guix processes --normalize
%rec: Session
%type: PID int
%type: ClientPID int
%key: PID

PID: 4278
ClientPID: 4268
ClientCommand: /gnu/store/...

%rec: Lock
%type: Session rec Session

%rec: ChildProcess
%type: Session rec Session
%type: PID int
%key: PID

Session: 4278
PID: 4435
Command: /gnu/store/...

Session: 4278
PID: 4554
Command: /gnu/store/...

Session: 4278
PID: 4646
Command: guile --no-auto-compile ...

---- End ----

What do you think?

John
J
J
John Soo wrote on 5 Nov 2020 16:49
processes: Don't normalize Locks
(address . 44460@debbugs.gnu.org)
87k0uzvm5l.fsf@asu.edu
I got a little eager to normalize and put locks in their own record
set. That was unnecessary as records can have multiple of the same field
name. This new patch removes the Lock record set and puts the Lock in
the Session record.

- John
J
J
L
L
Ludovic Courtès wrote on 10 Nov 2020 23:15
(name . John Soo)(address . jsoo1@asu.edu)(address . 44460@debbugs.gnu.org)
87k0usn9jk.fsf@gnu.org
Hi John,

John Soo <jsoo1@asu.edu> skribis:

Toggle quote (7 lines)
>>From 48945997d9139ddc5e288512de3dda8d5accaf44 Mon Sep 17 00:00:00 2001
> From: John Soo <jsoo1@asu.edu>
> Date: Wed, 4 Nov 2020 07:51:52 -0800
> Subject: [PATCH] processes: Optionally normalize recutils output.
>
> * guix/scripts/processes.scm: Add "normalize" flag

[...]

Toggle quote (24 lines)
> +@table @code
> +@item --normalize
> +Normalize the output records into record sets (@pxref{Record Sets,,,
> +recutils, GNU recutils manual}). Normalizing into record sets allows
> +joins across record types.
> +
> +@example
> +$ guix processes --normalize | \
> + recsel \
> + -j Session \
> + -t ChildProcess \
> + -p Session.PID,PID \
> + -e 'Session.ClientCommand ~ build'
> +Session_PID: 4278
> +PID: 4435
> +
> +Session_PID: 4278
> +PID: 4554
> +
> +Session_PID: 4278
> +PID: 4646
> +@end example
> +@end table

Nice! Right above the example, I’d suggest adding a sentence like “The
example below lists…” (what does it list actually? :-)).

In the default format, I wonder if we could already change split
‘ChildProcess’ into ‘ChildPID’ and ‘ChildCommand’, as you had initially
proposed on IRC; would that work?

Toggle quote (3 lines)
> +(define (lock->record lock port)
> + (format port "LockHeld: ~a~%" lock))

Maybe ‘lock->recutils’ for consistency and to avoid confusion with
Scheme “records”?

Toggle quote (2 lines)
> +(define (format-single-record port)

Maybe ‘daemon-sessions->recutils’? Should ‘sessions’ be a parameter for
clarity?

Toggle quote (4 lines)
> + "Display denormalized session information to PORT."
> + (for-each (lambda (session)
> + (daemon-session->recutils session port)
> + (newline port))
^
Indentation is off.

Toggle quote (8 lines)
> +(define (child-process->normalized-record process port)
> + "Display PROCESS record on PORT in normalized form"
> + (format port "PID: ~a" (process-id process))
> + (newline port)
> + (format port "Command:~{ ~a~}" (process-command process)))
> +
> +(define (format-normalized port)

Please add a docstring. Perhaps make ‘sessions’ a parameter?

Toggle quote (4 lines)
> + (define sessions (daemon-sessions))
> +
> + (format port session-rec-type)

As reported by ‘-Wformat’, passing a non-literal format string is risky;
write this instead:

(display session-rec-type port)

Toggle quote (5 lines)
> + (newline port)
> + (newline port)
> + (for-each
> + (lambda (session)

Preferable indent ‘for-each’ like so:

(for-each (lambda (session)

Likewise below.

Toggle quote (3 lines)
> + (display (G_ "
> + --normalize display results as normalized record sets"))

Should it be ‘--format=normalized’ (just like we have ‘--format’ in
‘guix describe’, for instance)?

Could you send an updated patch?

Thanks!

Ludo’.
J
J
John Soo wrote on 11 Nov 2020 18:51
(name . Ludovic Courtès)(address . ludo@gnu.org)(address . 44460@debbugs.gnu.org)
87imabok8j.fsf@asu.edu
Hello Ludo,

Ludovic Courtès <ludo@gnu.org> writes:

Toggle quote (31 lines)
>> +@table @code
>> +@item --normalize
>> +Normalize the output records into record sets (@pxref{Record Sets,,,
>> +recutils, GNU recutils manual}). Normalizing into record sets allows
>> +joins across record types.
>> +
>> +@example
>> +$ guix processes --normalize | \
>> + recsel \
>> + -j Session \
>> + -t ChildProcess \
>> + -p Session.PID,PID \
>> + -e 'Session.ClientCommand ~ build'
>> +Session_PID: 4278
>> +PID: 4435
>> +
>> +Session_PID: 4278
>> +PID: 4554
>> +
>> +Session_PID: 4278
>> +PID: 4646
>> +@end example
>> +@end table
>
> Nice! Right above the example, I’d suggest adding a sentence like “The
> example below lists…” (what does it list actually? :-)).
>
> In the default format, I wonder if we could already change split
> ‘ChildProcess’ into ‘ChildPID’ and ‘ChildCommand’, as you had initially
> proposed on IRC; would that work?

I think we could do that, but I had two reasons to use the normalized
format instead.

* Backwards incompatibility - I didn't want to break any existing scripts
that may exist.

* Still not normalized - how can I search for just the child processes
associated with a particular command?

I wouldn't be opposed to splitting ChildProcess into ChildPID and
ChildCommand. I would like it best if that change was made in addition
to adding the normalized version, since the normalized version allows
more functionality.

Toggle quote (6 lines)
>> +(define (lock->record lock port)
>> + (format port "LockHeld: ~a~%" lock))
>
> Maybe ‘lock->recutils’ for consistency and to avoid confusion with
> Scheme “records”?

Done.

Toggle quote (5 lines)
>> +(define (format-single-record port)
>
> Maybe ‘daemon-sessions->recutils’? Should ‘sessions’ be a parameter for
> clarity?

Much better, thank you. I updated the normalized version too.

Toggle quote (8 lines)
>
>> + "Display denormalized session information to PORT."
>> + (for-each (lambda (session)
>> + (daemon-session->recutils session port)
>> + (newline port))
> ^
> Indentation is off.

Fixed.

Toggle quote (10 lines)
>> +(define (child-process->normalized-record process port)
>> + "Display PROCESS record on PORT in normalized form"
>> + (format port "PID: ~a" (process-id process))
>> + (newline port)
>> + (format port "Command:~{ ~a~}" (process-command process)))
>> +
>> +(define (format-normalized port)
>
> Please add a docstring. Perhaps make ‘sessions’ a parameter?

Done.

Toggle quote (9 lines)
>> + (define sessions (daemon-sessions))
>> +
>> + (format port session-rec-type)
>
> As reported by ‘-Wformat’, passing a non-literal format string is risky;
> write this instead:
>
> (display session-rec-type port)

Done.

Toggle quote (9 lines)
>> + (newline port)
>> + (newline port)
>> + (for-each
>> + (lambda (session)
>
> Preferable indent ‘for-each’ like so:
>
> (for-each (lambda (session)

Done.

Toggle quote (8 lines)
> Likewise below.
>
>> + (display (G_ "
>> + --normalize display results as normalized record sets"))
>
> Should it be ‘--format=normalized’ (just like we have ‘--format’ in
> ‘guix describe’, for instance)?

That makes sense. What do you think of

Other changes:

* Updated the record descriptors to include the possible
fields for sessions. I got some nice guidance from the recutils irc on
that.

* Put the PID and Command first for the ChildProcess

* Add a --list-formats like guix describe has.

Thanks!

John
J
J
L
L
Ludovic Courtès wrote on 12 Nov 2020 11:58
(name . John Soo)(address . jsoo1@asu.edu)(address . 44460@debbugs.gnu.org)
87ft5elu45.fsf@gnu.org
Hi John,

John Soo <jsoo1@asu.edu> skribis:


[...]

Toggle quote (21 lines)
>>> +Session_PID: 4278
>>> +PID: 4646
>>> +@end example
>>> +@end table
>>
>> Nice! Right above the example, I’d suggest adding a sentence like “The
>> example below lists…” (what does it list actually? :-)).
>>
>> In the default format, I wonder if we could already change split
>> ‘ChildProcess’ into ‘ChildPID’ and ‘ChildCommand’, as you had initially
>> proposed on IRC; would that work?
>
> I think we could do that, but I had two reasons to use the normalized
> format instead.
>
> * Backwards incompatibility - I didn't want to break any existing scripts
> that may exist.
>
> * Still not normalized - how can I search for just the child processes
> associated with a particular command?

Like:

guix processes | recsel -e 'ClientCommand ~ "xyz"' -p ChildProcess

?

Actually what does “normalized” mean in this context?

Toggle quote (5 lines)
> I wouldn't be opposed to splitting ChildProcess into ChildPID and
> ChildCommand. I would like it best if that change was made in addition
> to adding the normalized version, since the normalized version allows
> more functionality.

I would think it’s OK to break compatibility on just these
“ChildProcess” fields.

Toggle quote (8 lines)
> * Updated the record descriptors to include the possible
> fields for sessions. I got some nice guidance from the recutils irc on
> that.
>
> * Put the PID and Command first for the ChildProcess
>
> * Add a --list-formats like guix describe has.

Great, I’ll take a look. Thanks!

Ludo’.
J
J
John Soo wrote on 12 Nov 2020 16:37
(name . Ludovic Courtès)(address . ludo@gnu.org)(address . 44460@debbugs.gnu.org)
87361eoabg.fsf@asu.edu
Hi Ludo,

Ludovic Courtès <ludo@gnu.org> writes:

Toggle quote (11 lines)
>> * Still not normalized - how can I search for just the child processes
>> associated with a particular command?
>
> Like:
>
> guix processes | recsel -e 'ClientCommand ~ "xyz"' -p ChildProcess
>
> ?
>
> Actually what does “normalized” mean in this context?

Excellent question. I was thinking along the lines of database
normalization. The default output has multi-valued fields for child
processes, so the idea is to make them their own record set. Does that
make sense?

An aside - Probably to be entirely honest about normalizing the output,
locks really would be in a separate record set too.

Another challenge is making sure the user can understand what
"normalized" means. I am not sure readers of the manual/cli help will
be able to infer what it means from context. On the other hand, it is
such a small use case that it seems imbalanced to provide a lot of
background for the term "normal". What do you think?

Toggle quote (8 lines)
>> I wouldn't be opposed to splitting ChildProcess into ChildPID and
>> ChildCommand. I would like it best if that change was made in addition
>> to adding the normalized version, since the normalized version allows
>> more functionality.
>
> I would think it’s OK to break compatibility on just these
> “ChildProcess” fields.

Ok. Would it be ok if I put that in a separate commit?

Thanks again!

- John
L
L
Ludovic Courtès wrote on 12 Nov 2020 21:29
(name . John Soo)(address . jsoo1@asu.edu)(address . 44460@debbugs.gnu.org)
871rgyiajk.fsf@gnu.org
Hi,

John Soo <jsoo1@asu.edu> skribis:

Toggle quote (18 lines)
> Ludovic Courtès <ludo@gnu.org> writes:
>
>>> * Still not normalized - how can I search for just the child processes
>>> associated with a particular command?
>>
>> Like:
>>
>> guix processes | recsel -e 'ClientCommand ~ "xyz"' -p ChildProcess
>>
>> ?
>>
>> Actually what does “normalized” mean in this context?
>
> Excellent question. I was thinking along the lines of database
> normalization. The default output has multi-valued fields for child
> processes, so the idea is to make them their own record set. Does that
> make sense?

Yes it does! Initially I wondered if it was a term used in recutils,
but apparently it’s not.

Toggle quote (3 lines)
> An aside - Probably to be entirely honest about normalizing the output,
> locks really would be in a separate record set too.

Yeah.

Toggle quote (6 lines)
> Another challenge is making sure the user can understand what
> "normalized" means. I am not sure readers of the manual/cli help will
> be able to infer what it means from context. On the other hand, it is
> such a small use case that it seems imbalanced to provide a lot of
> background for the term "normal". What do you think?

Sure.

Thinking more about it, to me the appeal of recutils is that it’s both
human- and machine-readable. But here we end up having a specific
machine-readable variant. But yeah, maybe that’s unavoidable.

Toggle quote (10 lines)
>>> I wouldn't be opposed to splitting ChildProcess into ChildPID and
>>> ChildCommand. I would like it best if that change was made in addition
>>> to adding the normalized version, since the normalized version allows
>>> more functionality.
>>
>> I would think it’s OK to break compatibility on just these
>> “ChildProcess” fields.
>
> Ok. Would it be ok if I put that in a separate commit?

Yes (you mean in addition to ‘-f normalized’, right?).

Thanks,
Ludo’.
J
J
John Soo wrote on 13 Nov 2020 06:33
(name . Ludovic Courtès)(address . ludo@gnu.org)(address . 44460@debbugs.gnu.org)
87pn4hn7lr.fsf@asu.edu
Hi Ludo,

Ludovic Courtès <ludo@gnu.org> writes:

Toggle quote (3 lines)
> Yes it does! Initially I wondered if it was a term used in recutils,
> but apparently it’s not.

Do you think it is the best term to use?

Toggle quote (5 lines)
>> An aside - Probably to be entirely honest about normalizing the output,
>> locks really would be in a separate record set too.
>
> Yeah.

I made Lock a separate record set. This exposes a limitation with
recutils. It is not possible to join more than two record sets together
(though they mentioned it as a goal on IRC).

Toggle quote (12 lines)
>> Another challenge is making sure the user can understand what
>> "normalized" means. I am not sure readers of the manual/cli help will
>> be able to infer what it means from context. On the other hand, it is
>> such a small use case that it seems imbalanced to provide a lot of
>> background for the term "normal". What do you think?
>
> Sure.
>
> Thinking more about it, to me the appeal of recutils is that it’s both
> human- and machine-readable. But here we end up having a specific
> machine-readable variant. But yeah, maybe that’s unavoidable.

I suppose the normalized version is a little less human-readable. It
would be behind a flag, though. Is that a reasonable compromise?

After some thought I realize that the normalized version isn't that much
more useful than the default, but it does enable things like:

---- Example ----
$ guix processes -f normalized \
| recsel \
-t ChildProcess \
-j Session \
-p PID,Session.PID \
| recfmt '{{PID}} {{Session.PID}}'
23607 2356724713 2356725002 23576
---- Example ----

This will format all the (PID, Session) pairs. Whereas the
non-normalized version would only print one PID given the following.

---- Example ----
$ guix processes \
| recsel -p ChildPID,SessionPID \
| recfmt '{{ChildPID}} {{SessionPID}}'
23607 23567
---

Toggle quote (12 lines)
>>>> I wouldn't be opposed to splitting ChildProcess into ChildPID and
>>>> ChildCommand. I would like it best if that change was made in addition
>>>> to adding the normalized version, since the normalized version allows
>>>> more functionality.
>>>
>>> I would think it’s OK to break compatibility on just these
>>> “ChildProcess” fields.
>>
>> Ok. Would it be ok if I put that in a separate commit?
>
> Yes (you mean in addition to ‘-f normalized’, right?).

I changed ChildProcess: pid: command to ChildPID and ChildCommand in the
default in a separate commit.

Thanks again,

John
From 6082c559d1200e632b3fb45eb0633d28829667a1 Mon Sep 17 00:00:00 2001
From: John Soo <jsoo1@asu.edu>
Date: Thu, 12 Nov 2020 21:16:48 -0800
Subject: [PATCH 1/2] processes: Put ChildProcess and ChildPID on separate
lines.

* guix/scripts/processes.scm: Put child process information in
separate fields.
* doc/guix.texi: Document change in output of guix processes.
---
doc/guix.texi | 22 +++++++++++++---------
guix/scripts/processes.scm | 6 ++++--
2 files changed, 17 insertions(+), 11 deletions(-)

Toggle diff (72 lines)
diff --git a/doc/guix.texi b/doc/guix.texi
index 5e3e0435b4..e8814c686c 100644
--- a/doc/guix.texi
+++ b/doc/guix.texi
@@ -82,6 +82,7 @@ Copyright @copyright{} 2020 Pierre Langlois@*
Copyright @copyright{} 2020 pinoaffe@*
Copyright @copyright{} 2020 André Batista@*
Copyright @copyright{} 2020 Alexandru-Sergiu Marton@*
+Copyright @copyright{} 2020 John Soo@*
Permission is granted to copy, distribute and/or modify this document
under the terms of the GNU Free Documentation License, Version 1.3 or
@@ -12661,9 +12662,12 @@ ClientCommand: cuirass --cache-directory /var/cache/cuirass @dots{}
LockHeld: /gnu/store/@dots{}-perl-ipc-cmd-0.96.lock
LockHeld: /gnu/store/@dots{}-python-six-bootstrap-1.11.0.lock
LockHeld: /gnu/store/@dots{}-libjpeg-turbo-2.0.0.lock
-ChildProcess: 20495: guix offload x86_64-linux 7200 1 28800
-ChildProcess: 27733: guix offload x86_64-linux 7200 1 28800
-ChildProcess: 27793: guix offload x86_64-linux 7200 1 28800
+ChildPID: 20495
+ChildCommand: guix offload x86_64-linux 7200 1 28800
+ChildPID: 27733
+ChildCommand: guix offload x86_64-linux 7200 1 28800
+ChildPID: 27793
+ChildCommand: guix offload x86_64-linux 7200 1 28800
@end example
In this example we see that @command{guix-daemon} has three clients:
@@ -12672,12 +12676,12 @@ integration tool; their process identifier (PID) is given by the
@code{ClientPID} field. The @code{SessionPID} field gives the PID of the
@command{guix-daemon} sub-process of this particular session.
-The @code{LockHeld} fields show which store items are currently locked by this
-session, which corresponds to store items being built or substituted (the
-@code{LockHeld} field is not displayed when @command{guix processes} is not
-running as root). Last, by looking at the @code{ChildProcess} field, we
-understand that these three builds are being offloaded (@pxref{Daemon Offload
-Setup}).
+The @code{LockHeld} fields show which store items are currently locked
+by this session, which corresponds to store items being built or
+substituted (the @code{LockHeld} field is not displayed when
+@command{guix processes} is not running as root). Last, by looking at
+the @code{ChildPID} and @code{ChildCommand} fields, we understand that
+these three builds are being offloaded (@pxref{Daemon Offload Setup}).
The output is in Recutils format so we can use the handy @command{recsel}
command to select sessions of interest (@pxref{Selection Expressions,,,
diff --git a/guix/scripts/processes.scm b/guix/scripts/processes.scm
index b4ca7b1687..3a7ea0b89c 100644
--- a/guix/scripts/processes.scm
+++ b/guix/scripts/processes.scm
@@ -1,5 +1,6 @@
;;; GNU Guix --- Functional package management for GNU
;;; Copyright © 2018, 2019, 2020 Ludovic Courtès <ludo@gnu.org>
+;;; Copyright © 2020 John Soo <jsoo1@asu.edu>
;;;
;;; This file is part of GNU Guix.
;;;
@@ -188,8 +189,9 @@ active sessions, and the master 'guix-daemon' process."
(format port "LockHeld: ~a~%" lock))
(daemon-session-locks-held session))
(for-each (lambda (process)
- (format port "ChildProcess: ~a:~{ ~a~}~%"
- (process-id process)
+ (format port "ChildPID: ~a~%"
+ (process-id process))
+ (format port "ChildCommand: :~{ ~a~}~%"
(process-command process)))
(daemon-session-children session)))
--
2.29.1
J
J
John Soo wrote on 13 Nov 2020 17:16
(name . Ludovic Courtès)(address . ludo@gnu.org)(address . 44460@debbugs.gnu.org)
87eekxxmee.fsf@asu.edu
Hello again,

No big changes here, I just forgot to update the manual again.

- John
From 6082c559d1200e632b3fb45eb0633d28829667a1 Mon Sep 17 00:00:00 2001
From: John Soo <jsoo1@asu.edu>
Date: Thu, 12 Nov 2020 21:16:48 -0800
Subject: [PATCH 1/2] processes: Put ChildProcess and ChildPID on separate
lines.

* guix/scripts/processes.scm: Put child process information in
separate fields.
* doc/guix.texi: Document change in output of guix processes.
---
doc/guix.texi | 22 +++++++++++++---------
guix/scripts/processes.scm | 6 ++++--
2 files changed, 17 insertions(+), 11 deletions(-)

Toggle diff (72 lines)
diff --git a/doc/guix.texi b/doc/guix.texi
index 5e3e0435b4..e8814c686c 100644
--- a/doc/guix.texi
+++ b/doc/guix.texi
@@ -82,6 +82,7 @@ Copyright @copyright{} 2020 Pierre Langlois@*
Copyright @copyright{} 2020 pinoaffe@*
Copyright @copyright{} 2020 André Batista@*
Copyright @copyright{} 2020 Alexandru-Sergiu Marton@*
+Copyright @copyright{} 2020 John Soo@*
Permission is granted to copy, distribute and/or modify this document
under the terms of the GNU Free Documentation License, Version 1.3 or
@@ -12661,9 +12662,12 @@ ClientCommand: cuirass --cache-directory /var/cache/cuirass @dots{}
LockHeld: /gnu/store/@dots{}-perl-ipc-cmd-0.96.lock
LockHeld: /gnu/store/@dots{}-python-six-bootstrap-1.11.0.lock
LockHeld: /gnu/store/@dots{}-libjpeg-turbo-2.0.0.lock
-ChildProcess: 20495: guix offload x86_64-linux 7200 1 28800
-ChildProcess: 27733: guix offload x86_64-linux 7200 1 28800
-ChildProcess: 27793: guix offload x86_64-linux 7200 1 28800
+ChildPID: 20495
+ChildCommand: guix offload x86_64-linux 7200 1 28800
+ChildPID: 27733
+ChildCommand: guix offload x86_64-linux 7200 1 28800
+ChildPID: 27793
+ChildCommand: guix offload x86_64-linux 7200 1 28800
@end example
In this example we see that @command{guix-daemon} has three clients:
@@ -12672,12 +12676,12 @@ integration tool; their process identifier (PID) is given by the
@code{ClientPID} field. The @code{SessionPID} field gives the PID of the
@command{guix-daemon} sub-process of this particular session.
-The @code{LockHeld} fields show which store items are currently locked by this
-session, which corresponds to store items being built or substituted (the
-@code{LockHeld} field is not displayed when @command{guix processes} is not
-running as root). Last, by looking at the @code{ChildProcess} field, we
-understand that these three builds are being offloaded (@pxref{Daemon Offload
-Setup}).
+The @code{LockHeld} fields show which store items are currently locked
+by this session, which corresponds to store items being built or
+substituted (the @code{LockHeld} field is not displayed when
+@command{guix processes} is not running as root). Last, by looking at
+the @code{ChildPID} and @code{ChildCommand} fields, we understand that
+these three builds are being offloaded (@pxref{Daemon Offload Setup}).
The output is in Recutils format so we can use the handy @command{recsel}
command to select sessions of interest (@pxref{Selection Expressions,,,
diff --git a/guix/scripts/processes.scm b/guix/scripts/processes.scm
index b4ca7b1687..3a7ea0b89c 100644
--- a/guix/scripts/processes.scm
+++ b/guix/scripts/processes.scm
@@ -1,5 +1,6 @@
;;; GNU Guix --- Functional package management for GNU
;;; Copyright © 2018, 2019, 2020 Ludovic Courtès <ludo@gnu.org>
+;;; Copyright © 2020 John Soo <jsoo1@asu.edu>
;;;
;;; This file is part of GNU Guix.
;;;
@@ -188,8 +189,9 @@ active sessions, and the master 'guix-daemon' process."
(format port "LockHeld: ~a~%" lock))
(daemon-session-locks-held session))
(for-each (lambda (process)
- (format port "ChildProcess: ~a:~{ ~a~}~%"
- (process-id process)
+ (format port "ChildPID: ~a~%"
+ (process-id process))
+ (format port "ChildCommand: :~{ ~a~}~%"
(process-command process)))
(daemon-session-children session)))
--
2.29.1
L
L
Ludovic Courtès wrote on 29 Nov 2020 23:49
(name . John Soo)(address . jsoo1@asu.edu)(address . 44460-done@debbugs.gnu.org)
87wny3ok17.fsf@gnu.org
Hi,

John Soo <jsoo1@asu.edu> skribis:

Toggle quote (10 lines)
>>From 6082c559d1200e632b3fb45eb0633d28829667a1 Mon Sep 17 00:00:00 2001
> From: John Soo <jsoo1@asu.edu>
> Date: Thu, 12 Nov 2020 21:16:48 -0800
> Subject: [PATCH 1/2] processes: Put ChildProcess and ChildPID on separate
> lines.
>
> * guix/scripts/processes.scm: Put child process information in
> separate fields.
> * doc/guix.texi: Document change in output of guix processes.

Applied.

Toggle quote (8 lines)
>>From becf3a8fee4aea0a49dde47f5728410b97d94fbf Mon Sep 17 00:00:00 2001
> From: John Soo <jsoo1@asu.edu>
> Date: Wed, 4 Nov 2020 07:51:52 -0800
> Subject: [PATCH 2/2] processes: Optionally normalize recutils output.
>
> * guix/scripts/processes.scm: Add "format" and "list-formats" flag.
> * doc/guix.texi: Document new flags.

Applied with the changes below.

I also tweaked the commit logs to list the entities added or modified.

Thanks!

Ludo’.
Toggle diff (48 lines)
diff --git a/doc/guix.texi b/doc/guix.texi
index b739464853..fcaa2f2b63 100644
--- a/doc/guix.texi
+++ b/doc/guix.texi
@@ -12884,14 +12884,15 @@ 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 ChildProcess as a field.
+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
-ChildProcess and the associated PID for Session that spawned the
-ChildProcess where the Session was started using guix build.
+@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 | \
@@ -12899,7 +12900,7 @@ $ guix processes --format=normalized | \
-j Session \
-t ChildProcess \
-p Session.PID,PID \
- -e 'Session.ClientCommand ~ "guix build'"
+ -e 'Session.ClientCommand ~ "guix build"'
PID: 4435
Session_PID: 4278
diff --git a/guix/scripts/processes.scm b/guix/scripts/processes.scm
index bcc541badb..87e687852c 100644
--- a/guix/scripts/processes.scm
+++ b/guix/scripts/processes.scm
@@ -338,8 +338,10 @@ List the current Guix sessions and their processes."))
(define-command (guix-processes . args)
(category plumbing)
(synopsis "list currently running sessions")
+
(define options
- (parse-command-line args %options (list %default-options)))
+ (parse-command-line args %options (list %default-options)
+ #:build-options? #f))
(with-paginated-output-port port
(match (assoc-ref options 'format)
Closed
?
Your comment

This issue is archived.

To comment on this conversation send an email to 44460@debbugs.gnu.org

To respond to this issue using the mumi CLI, first switch to it
mumi current 44460
Then, you may apply the latest patchset in this issue (with sign off)
mumi am -- -s
Or, compose a reply to this issue
mumi compose
Or, send patches to this issue
mumi send-email *.patch