From debbugs-submit-bounces@debbugs.gnu.org Wed Nov 04 23:31:16 2020 Received: (at submit) by debbugs.gnu.org; 5 Nov 2020 04:31:16 +0000 Received: from localhost ([127.0.0.1]:51315 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kaWvb-0001lW-B4 for submit@debbugs.gnu.org; Wed, 04 Nov 2020 23:31:16 -0500 Received: from lists.gnu.org ([209.51.188.17]:53536) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kaWvY-0001lO-QP for submit@debbugs.gnu.org; Wed, 04 Nov 2020 23:31:13 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:40760) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kaWvY-0003Gb-Eq for guix-patches@gnu.org; Wed, 04 Nov 2020 23:31:12 -0500 Received: from mail-pg1-x52f.google.com ([2607:f8b0:4864:20::52f]:40254) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kaWvT-0001yL-K0 for guix-patches@gnu.org; Wed, 04 Nov 2020 23:31:12 -0500 Received: by mail-pg1-x52f.google.com with SMTP id x13so410776pgp.7 for ; Wed, 04 Nov 2020 20:31:05 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=asu-edu.20150623.gappssmtp.com; s=20150623; h=from:to:subject:date:message-id:mime-version; bh=T+WyXqXVWzERGBPEyTgwODzuz6p8KyXmVE8A5B588+I=; b=webrDd4j1rd3Zws7QoKYXB5QQ0j/ThyJMI6RVmnIGgSyuBWTNNhPCRMHKCfj60Tk+O fVUnzadnfN3xCX6ANjQK6cNYwK4Sapc35nbaLXm6G7gFBNP4ozU0tU1ttDlUXNIBHexc PE7Uc9CSkm2sqygG4XcRrnXeJIAvchwezUiXHsGBNhtDIN9XGZSQnxBayxMAhwf2viXU vPvx7dPjBGFhL/uBZ3Bi1L+u6DbdYkScqj3y2KU7kXEiNFvyzxtNtPWM088fBSYSUGKG Dy+IdzbRiaz6dfvOliV2gNtNJgJAP52IVdRKX+LDrDtbYZPPB5wfsbs++LVZE8ATwrSF /4tQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:mime-version; bh=T+WyXqXVWzERGBPEyTgwODzuz6p8KyXmVE8A5B588+I=; b=Y3miVb7hMkl3jXczfou1wPeBQ3SHiq/+Jg0smKAXhKMcNWNlHI2SkMts/Qhmm+3m0r 5J9eqYh9UXY1AUHuyZFNYh+uRVpiJgrkns7ak0iXpLIe9pLeze9b09mixLSYRAxQ5zgp C4nkIZJeUKAuj+ADnmD4uwkHrcaPArdUtE3ynh6berphd3K6Lwg02ahyfq7Rbq9u8+4u ChXMMtX//RiGMSAhXkGj2fNFbDXKu1BFawvu5u3xmuCTKIx1vQ94OiUCOLD5YnYKZDHK +NVFgJyeqp3AE679D1VBmf1wfGOap+1EN/eyswYeimX61HF3mJjRrQIPJMYGzM60dcXj SK1A== X-Gm-Message-State: AOAM532L0SuA2WilvaCuGa9uE72jBN5Xk9CPXxB1l7k3HjlJ4ZdFlRZV 4bUyH6h5e3WRe2erEnZlNxJd/lIezMx9ng== X-Google-Smtp-Source: ABdhPJzHmbvTr6YuQKwWh1RPejdEyq8XLh2VzP8CI1AlWxCz3uv9400aXbmDDBS2CLo6DhMsmeJ3nQ== X-Received: by 2002:a62:834a:0:b029:18a:e0b1:f0d9 with SMTP id h71-20020a62834a0000b029018ae0b1f0d9mr606811pfe.73.1604550663848; Wed, 04 Nov 2020 20:31:03 -0800 (PST) Received: from ecenter ([2600:1700:83b0:8bd0::7a8]) by smtp.gmail.com with ESMTPSA id c127sm471694pfc.115.2020.11.04.20.31.02 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 04 Nov 2020 20:31:03 -0800 (PST) From: John Soo To: guix-patches@gnu.org Subject: [PATCH] processes: Optionally normalize recutils output. Date: Wed, 04 Nov 2020 20:31:01 -0800 Message-ID: <87o8kcv30a.fsf@asu.edu> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Received-SPF: pass client-ip=2607:f8b0:4864:20::52f; envelope-from=jsoo1@asu.edu; helo=mail-pg1-x52f.google.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-Spam-Score: -1.3 (-) X-Debbugs-Envelope-To: submit X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -2.3 (--) --=-=-= Content-Type: text/plain 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 --=-=-= Content-Type: text/x-patch Content-Disposition: attachment; filename=0001-processes-Optionally-normalize-recutils-output.patch >From 9c04e2d184977c95090ec237a6bc0334ee14a8e7 Mon Sep 17 00:00:00 2001 From: John Soo Date: Wed, 4 Nov 2020 07:51:52 -0800 Subject: [PATCH] processes: Optionally normalize recutils output. * guix/scripts/processes.scm: Add "normalize" flag --- doc/guix.texi | 26 ++++++++ guix/scripts/processes.scm | 121 +++++++++++++++++++++++++++++++++---- 2 files changed, 135 insertions(+), 12 deletions(-) diff --git a/doc/guix.texi b/doc/guix.texi index 5e3e0435b4..ed54c26072 100644 --- a/doc/guix.texi +++ b/doc/guix.texi @@ -12691,6 +12691,32 @@ ClientPID: 19419 ClientCommand: cuirass --cache-directory /var/cache/cuirass @dots{} @end example +Additional options are listed below. + +@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 + @node System Configuration @chapter System Configuration diff --git a/guix/scripts/processes.scm b/guix/scripts/processes.scm index b4ca7b1687..11cfd561b9 100644 --- a/guix/scripts/processes.scm +++ b/guix/scripts/processes.scm @@ -176,6 +176,9 @@ active sessions, and the master 'guix-daemon' process." (values (filter-map child-process->session children) master))) +(define (lock->record lock port) + (format port "LockHeld: ~a~%" lock)) + (define (daemon-session->recutils session port) "Display SESSION information in recutils format on PORT." (format port "SessionPID: ~a~%" @@ -184,8 +187,7 @@ active sessions, and the master 'guix-daemon' process." (process-id (daemon-session-client session))) (format port "ClientCommand:~{ ~a~}~%" (process-command (daemon-session-client session))) - (for-each (lambda (lock) - (format port "LockHeld: ~a~%" lock)) + (for-each (lambda (lock) (lock->record lock port)) (daemon-session-locks-held session)) (for-each (lambda (process) (format port "ChildProcess: ~a:~{ ~a~}~%" @@ -193,6 +195,98 @@ active sessions, and the master 'guix-daemon' process." (process-command process))) (daemon-session-children session))) +(define (format-single-record port) + "Display denormalized session information to PORT." + (for-each (lambda (session) + (daemon-session->recutils session port) + (newline port)) + (daemon-sessions))) + +(define session-rec-type + ;; Also includes ClientCommand but it doesn't seem to be possible to express + ;; a plain string field (the default) without further restrictions + "%rec: Session +%type: PID int +%type: ClientPID int +%key: PID") + +(define lock-rec-type + ;; Also includes LockHeld but it doesn't seem to be possible to express + ;; a plain string field (the default) without further restrictions + "%rec: Lock +%type: Session rec Session") + +(define child-process-rec-type + ;; Also includes Command but it doesn't seem to be possible to + ;; express a plain string field (the default) without further restrictions + "%rec: ChildProcess +%type: Session rec Session +%type: PID int +%key: PID") + +(define (session-pid-key->field session port) + "Display SESSION PID as field on PORT." + (format + port "Session: ~a" + (process-id (daemon-session-process session)))) + +(define (session-scalars->normalized-record session port) + "Display SESSION scalar fields to PORT in normalized form." + (format port "PID: ~a~%" + (process-id (daemon-session-process session))) + (format port "ClientPID: ~a~%" + (process-id (daemon-session-client session))) + (format port "ClientCommand:~{ ~a~}~%" + (process-command (daemon-session-client session)))) + +(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) + (define sessions (daemon-sessions)) + + (format port session-rec-type) + (newline port) + (newline port) + (for-each + (lambda (session) + (session-scalars->normalized-record session port)) + sessions) + (newline port) + + (format port lock-rec-type) + (newline port) + (newline port) + (for-each + (lambda (session) + (for-each + (lambda (lock) + (session-pid-key->field session port) + (newline port) + (lock->record lock port) + (newline port) + (newline port)) + (daemon-session-locks-held session))) + sessions) + + (format port child-process-rec-type) + (newline port) + (newline port) + (for-each + (lambda (session) + (for-each + (lambda (process) + (session-pid-key->field session port) + (newline port) + (child-process->normalized-record process port) + (newline port) + (newline port)) + (daemon-session-children session))) + sessions)) + ;;; ;;; Options. @@ -205,7 +299,10 @@ active sessions, and the master 'guix-daemon' process." (exit 0))) (option '(#\V "version") #f #f (lambda args - (show-version-and-exit "guix processes"))))) + (show-version-and-exit "guix processes"))) + (option '("normalize") #f #f + (lambda (opt name arg result) + (alist-cons 'normalize #t result))))) (define (show-help) (display (G_ "Usage: guix processes @@ -216,8 +313,13 @@ List the current Guix sessions and their processes.")) (display (G_ " -V, --version display version information and exit")) (newline) + (display (G_ " + --normalize display results as normalized record sets")) + (newline) (show-bug-report-information)) +(define %default-options '()) + ;;; ;;; Entry point. @@ -227,17 +329,12 @@ List the current Guix sessions and their processes.")) (category plumbing) (synopsis "list currently running sessions") (define options - (args-fold* args %options - (lambda (opt name arg result) - (leave (G_ "~A: unrecognized option~%") name)) - cons - '())) + (parse-command-line args %options (list %default-options))) (with-paginated-output-port port - (for-each (lambda (session) - (daemon-session->recutils session port) - (newline port)) - (daemon-sessions)) + (match (assoc-ref options 'normalize) + (#t (format-normalized port)) + (_ (format-single-record port))) ;; Pass 'R' (instead of 'r') so 'less' correctly estimates line length. #:less-options "FRX")) -- 2.29.1 --=-=-=-- From debbugs-submit-bounces@debbugs.gnu.org Thu Nov 05 10:49:54 2020 Received: (at 44460) by debbugs.gnu.org; 5 Nov 2020 15:49:54 +0000 Received: from localhost ([127.0.0.1]:53890 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kahWL-0006uN-Sw for submit@debbugs.gnu.org; Thu, 05 Nov 2020 10:49:54 -0500 Received: from mail-pf1-f172.google.com ([209.85.210.172]:41176) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kahWJ-0006u8-BJ for 44460@debbugs.gnu.org; Thu, 05 Nov 2020 10:49:52 -0500 Received: by mail-pf1-f172.google.com with SMTP id c20so1712747pfr.8 for <44460@debbugs.gnu.org>; Thu, 05 Nov 2020 07:49:51 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=asu-edu.20150623.gappssmtp.com; s=20150623; h=from:to:subject:date:message-id:mime-version; bh=ssvxzJ25+KPct7ekE1zy7PvsC+khKZoyXXv5suQF2gk=; b=gpOfaCDvqHtceRDKps05jWzaHpGlbEtBq5rxgsqvp053G+qF8aUeIzvD1IzAtqwZzn 8UL3HkqZSoPpvqZ7qBg7u9+JQ+NaUwPDc7WreVL0uwFYe7oNNtkcVgIcNx6ZOuSYDC47 Q2WfMSJ3ajxxfbwQlheAv7nDoAtqosbB2dbVOgYAgcqM3fw4Aq0b5SUy0Pb0s5jP1C4v 7HbioQ3C2Py+Ldu67Zl/AXfqpw0gPVEnOV+6gS7qH/Nqt1Te3slBzq7RDW9iw4UNksjh Tg8ijrWmG2VIHwpqgyediPlf0mqbbqGXkLdEC8Pw9zXjETuaau0N1F8JoN+/RCzExr0B U2Jg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:mime-version; bh=ssvxzJ25+KPct7ekE1zy7PvsC+khKZoyXXv5suQF2gk=; b=XmEsjbDj6EbGnfcdYVciTzO9gl1bXDBdeQqoMCzZxacYPmSkbCq+FBJ6AsLOtq6eCA gWmB0s2lyVpUaaFqSWUraL49zZtTgpCKVhD3viaxuDe7W5FkL934fzg5K2pkZamelUGd 7PHVmu4x9IGwEvopK0nvDUvfw+BGZ8Gmkyo6SYiDc7KWX9eV35Dvpbl6C2NPpDR3zzCD 7SFn/x2+J4DJUWViZ68YJpqhn7lW2+hYpP1PEL4pOu9Lq4NMI0EhwWTaSKHraU7479kN ao83mqxT6EGZfie/ZjqebLBUvgXdox2O45YTEZw2IlKyr1bw3KIObszxVimpP5iGGMwe 120A== X-Gm-Message-State: AOAM531LbJ8T/9w/LhN6OVbxL5M6y26zdRs40THaA7vZrdgD4bIHTFIi AGMy2xe5KLH7Ne3TJ1GEhTgj0PlrE4n4ZQ== X-Google-Smtp-Source: ABdhPJw7HE+/tQoLT1aG2hLVzlfZUhR+rrjJ3npQRS2NCmiRIc/8Q8zxBWdTO9BUaxx+Qgrqti4QiA== X-Received: by 2002:a63:ec0d:: with SMTP id j13mr2966904pgh.281.1604591384807; Thu, 05 Nov 2020 07:49:44 -0800 (PST) Received: from ecenter ([2600:1700:83b0:8bd0::7a8]) by smtp.gmail.com with ESMTPSA id m129sm3035264pfd.177.2020.11.05.07.49.43 for <44460@debbugs.gnu.org> (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 05 Nov 2020 07:49:43 -0800 (PST) From: John Soo To: 44460@debbugs.gnu.org Subject: processes: Don't normalize Locks Date: Thu, 05 Nov 2020 07:49:42 -0800 Message-ID: <87k0uzvm5l.fsf@asu.edu> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Spam-Score: -0.0 (/) X-Debbugs-Envelope-To: 44460 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) --=-=-= Content-Type: text/plain 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 --=-=-= Content-Type: text/x-patch Content-Disposition: attachment; filename=0001-processes-Optionally-normalize-recutils-output.patch >From 699c66987885d91788ea0707a819270ca9fb2e1e Mon Sep 17 00:00:00 2001 From: John Soo Date: Wed, 4 Nov 2020 07:51:52 -0800 Subject: [PATCH] processes: Optionally normalize recutils output. * guix/scripts/processes.scm: Add "normalize" flag --- doc/guix.texi | 26 ++++++++++ guix/scripts/processes.scm | 103 ++++++++++++++++++++++++++++++++----- 2 files changed, 117 insertions(+), 12 deletions(-) diff --git a/doc/guix.texi b/doc/guix.texi index 5e3e0435b4..ed54c26072 100644 --- a/doc/guix.texi +++ b/doc/guix.texi @@ -12691,6 +12691,32 @@ ClientPID: 19419 ClientCommand: cuirass --cache-directory /var/cache/cuirass @dots{} @end example +Additional options are listed below. + +@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 + @node System Configuration @chapter System Configuration diff --git a/guix/scripts/processes.scm b/guix/scripts/processes.scm index b4ca7b1687..6828cf576e 100644 --- a/guix/scripts/processes.scm +++ b/guix/scripts/processes.scm @@ -176,6 +176,9 @@ active sessions, and the master 'guix-daemon' process." (values (filter-map child-process->session children) master))) +(define (lock->record lock port) + (format port "LockHeld: ~a~%" lock)) + (define (daemon-session->recutils session port) "Display SESSION information in recutils format on PORT." (format port "SessionPID: ~a~%" @@ -184,8 +187,7 @@ active sessions, and the master 'guix-daemon' process." (process-id (daemon-session-client session))) (format port "ClientCommand:~{ ~a~}~%" (process-command (daemon-session-client session))) - (for-each (lambda (lock) - (format port "LockHeld: ~a~%" lock)) + (for-each (lambda (lock) (lock->record lock port)) (daemon-session-locks-held session)) (for-each (lambda (process) (format port "ChildProcess: ~a:~{ ~a~}~%" @@ -193,6 +195,80 @@ active sessions, and the master 'guix-daemon' process." (process-command process))) (daemon-session-children session))) +(define (format-single-record port) + "Display denormalized session information to PORT." + (for-each (lambda (session) + (daemon-session->recutils session port) + (newline port)) + (daemon-sessions))) + +(define session-rec-type + ;; Also includes ClientCommand and LockHeld but it doesn't seem to be + ;; possible to express a plain string field (the default) without further + ;; restrictions + "%rec: Session +%type: PID int +%type: ClientPID int +%key: PID") + +(define child-process-rec-type + ;; Also includes Command but it doesn't seem to be possible to + ;; express a plain string field (the default) without further restrictions + "%rec: ChildProcess +%type: Session rec Session +%type: PID int +%key: PID") + +(define (session-key->field session port) + "Display SESSION PID as field on PORT." + (format + port "Session: ~a" + (process-id (daemon-session-process session)))) + +(define (session-scalars->normalized-record session port) + "Display SESSION scalar fields to PORT in normalized form." + (format port "PID: ~a~%" + (process-id (daemon-session-process session))) + (format port "ClientPID: ~a~%" + (process-id (daemon-session-client session))) + (format port "ClientCommand:~{ ~a~}~%" + (process-command (daemon-session-client session)))) + +(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) + (define sessions (daemon-sessions)) + + (format port session-rec-type) + (newline port) + (newline port) + (for-each + (lambda (session) + (session-scalars->normalized-record session port) + (for-each (lambda (lock) (lock->record lock port)) + (daemon-session-locks-held session))) + sessions) + (newline port) + + (format port child-process-rec-type) + (newline port) + (newline port) + (for-each + (lambda (session) + (for-each + (lambda (process) + (session-key->field session port) + (newline port) + (child-process->normalized-record process port) + (newline port) + (newline port)) + (daemon-session-children session))) + sessions)) + ;;; ;;; Options. @@ -205,7 +281,10 @@ active sessions, and the master 'guix-daemon' process." (exit 0))) (option '(#\V "version") #f #f (lambda args - (show-version-and-exit "guix processes"))))) + (show-version-and-exit "guix processes"))) + (option '("normalize") #f #f + (lambda (opt name arg result) + (alist-cons 'normalize #t result))))) (define (show-help) (display (G_ "Usage: guix processes @@ -216,8 +295,13 @@ List the current Guix sessions and their processes.")) (display (G_ " -V, --version display version information and exit")) (newline) + (display (G_ " + --normalize display results as normalized record sets")) + (newline) (show-bug-report-information)) +(define %default-options '()) + ;;; ;;; Entry point. @@ -227,17 +311,12 @@ List the current Guix sessions and their processes.")) (category plumbing) (synopsis "list currently running sessions") (define options - (args-fold* args %options - (lambda (opt name arg result) - (leave (G_ "~A: unrecognized option~%") name)) - cons - '())) + (parse-command-line args %options (list %default-options))) (with-paginated-output-port port - (for-each (lambda (session) - (daemon-session->recutils session port) - (newline port)) - (daemon-sessions)) + (match (assoc-ref options 'normalize) + (#t (format-normalized port)) + (_ (format-single-record port))) ;; Pass 'R' (instead of 'r') so 'less' correctly estimates line length. #:less-options "FRX")) -- 2.29.1 --=-=-=-- From debbugs-submit-bounces@debbugs.gnu.org Thu Nov 05 11:01:51 2020 Received: (at 44460) by debbugs.gnu.org; 5 Nov 2020 16:01:51 +0000 Received: from localhost ([127.0.0.1]:53915 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kahhu-0007Eo-M3 for submit@debbugs.gnu.org; Thu, 05 Nov 2020 11:01:51 -0500 Received: from mail-pg1-f169.google.com ([209.85.215.169]:38620) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kahhs-0007Ea-Pr for 44460@debbugs.gnu.org; Thu, 05 Nov 2020 11:01:49 -0500 Received: by mail-pg1-f169.google.com with SMTP id i26so1685245pgl.5 for <44460@debbugs.gnu.org>; Thu, 05 Nov 2020 08:01:48 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=asu-edu.20150623.gappssmtp.com; s=20150623; h=from:to:subject:date:message-id:mime-version; bh=syArphyHccnKoqq1cGTJIOEdrhue1AJ1hneCKW1wfdA=; b=gW2QK7M65j2EJw/ZokAXzgBH254WkiHd7QA59utCqH925GHdYUn2nVvwRV5m+LiADo k2q0sDM8m1tigoPr84GKXFi1qvhL9FzdpUEUBJ3ez4UL7bqB0MwJ9kEr8DDD0Cmqa92T qzI3ZpZvsyoALSQFm9gv5Avyxu623QhMeFmLHtNFNwUg4KBSECG/CV7qrX9dX6CTKysK UMLmx3MalLGWIjO2IJdBlRetiaM/OQ5Q1KZWnZp6o6i5pmaOGb33izQquB7HEcX+wGuV oOa/f80bSURTXl+jZRe+cVvMF6IsZdxD7Y6hr1J5xmKWRDCyktFCoVyARQGjzIOgxVpv 2qMw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:mime-version; bh=syArphyHccnKoqq1cGTJIOEdrhue1AJ1hneCKW1wfdA=; b=Vt3KbZUrDCMACfay9HzImm3r1NfNYSE/lpQMiRhyHR7o9cKwFntpgcaNJU9bgEM7LT tLIRTIphCqYHv480aqFjvp6nMokkauWmEwdMIF3XS8JHKYiYJnjH9OhLNirLI5oHu4KC O2YggmK1P4mTxw3Uf/LSTuJZFTW8wbcnNY4DfEyqwkB7HyH5CmLL4V00egpMaQjdNzTK uyt3fT9+BICa/AnnR5l7wt8PLUZ0LB2FgHDwNt7SiZRHtjFMyoax0MtdCJvtP2UyDoyJ eHJwnctFHGlf1we6BAQDjSw4RtU8wIbs9zeVnYkLUZY3p+Q716bnC7XC/eeVl/zv0HGN LTkw== X-Gm-Message-State: AOAM530O9BE4XKO2OzEVdOztayNTeZ/AuAv8VUu2Dv4QstpXq2tT9HW/ Fev2yYiK+/oz6arwIu/5O+730gacKbDQXQ== X-Google-Smtp-Source: ABdhPJwwcSGFfjWhNlCDadGhF0IItPOrfbR0lv64KX608YNea+zJWqE4n0+DAzgfWopvfejBnt5Aow== X-Received: by 2002:a63:af08:: with SMTP id w8mr3037067pge.419.1604592102495; Thu, 05 Nov 2020 08:01:42 -0800 (PST) Received: from ecenter ([2600:1700:83b0:8bd0::7a8]) by smtp.gmail.com with ESMTPSA id js7sm2660555pjb.46.2020.11.05.08.01.41 for <44460@debbugs.gnu.org> (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 05 Nov 2020 08:01:41 -0800 (PST) From: John Soo To: 44460@debbugs.gnu.org Subject: Fixup the output of Session Date: Thu, 05 Nov 2020 08:01:40 -0800 Message-ID: <87h7q3vlln.fsf@asu.edu> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 44460 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) --=-=-= Content-Type: text/plain I had too many newlines after the session recordset and too few between session records. - John --=-=-= Content-Type: text/x-patch Content-Disposition: attachment; filename=0001-processes-Optionally-normalize-recutils-output.patch >From 26ed1a755966d20cb5f2cd8a77d55a981fe6e965 Mon Sep 17 00:00:00 2001 From: John Soo Date: Wed, 4 Nov 2020 07:51:52 -0800 Subject: [PATCH] processes: Optionally normalize recutils output. * guix/scripts/processes.scm: Add "normalize" flag --- doc/guix.texi | 26 ++++++++++ guix/scripts/processes.scm | 104 ++++++++++++++++++++++++++++++++----- 2 files changed, 118 insertions(+), 12 deletions(-) diff --git a/doc/guix.texi b/doc/guix.texi index 5e3e0435b4..ed54c26072 100644 --- a/doc/guix.texi +++ b/doc/guix.texi @@ -12691,6 +12691,32 @@ ClientPID: 19419 ClientCommand: cuirass --cache-directory /var/cache/cuirass @dots{} @end example +Additional options are listed below. + +@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 + @node System Configuration @chapter System Configuration diff --git a/guix/scripts/processes.scm b/guix/scripts/processes.scm index b4ca7b1687..6497cd5c2f 100644 --- a/guix/scripts/processes.scm +++ b/guix/scripts/processes.scm @@ -176,6 +176,9 @@ active sessions, and the master 'guix-daemon' process." (values (filter-map child-process->session children) master))) +(define (lock->record lock port) + (format port "LockHeld: ~a~%" lock)) + (define (daemon-session->recutils session port) "Display SESSION information in recutils format on PORT." (format port "SessionPID: ~a~%" @@ -184,8 +187,7 @@ active sessions, and the master 'guix-daemon' process." (process-id (daemon-session-client session))) (format port "ClientCommand:~{ ~a~}~%" (process-command (daemon-session-client session))) - (for-each (lambda (lock) - (format port "LockHeld: ~a~%" lock)) + (for-each (lambda (lock) (lock->record lock port)) (daemon-session-locks-held session)) (for-each (lambda (process) (format port "ChildProcess: ~a:~{ ~a~}~%" @@ -193,6 +195,81 @@ active sessions, and the master 'guix-daemon' process." (process-command process))) (daemon-session-children session))) +(define (format-single-record port) + "Display denormalized session information to PORT." + (for-each (lambda (session) + (daemon-session->recutils session port) + (newline port)) + (daemon-sessions))) + +(define session-rec-type + ;; Also includes ClientCommand and LockHeld but it doesn't seem to be + ;; possible to express a plain string field (the default) without further + ;; restrictions + "%rec: Session +%type: PID int +%type: ClientPID int +%key: PID") + +(define child-process-rec-type + ;; Also includes Command but it doesn't seem to be possible to + ;; express a plain string field (the default) without further restrictions + "%rec: ChildProcess +%type: Session rec Session +%type: PID int +%key: PID") + +(define (session-key->field session port) + "Display SESSION PID as field on PORT." + (format + port "Session: ~a" + (process-id (daemon-session-process session)))) + +(define (session-scalars->normalized-record session port) + "Display SESSION scalar fields to PORT in normalized form." + (format port "PID: ~a~%" + (process-id (daemon-session-process session))) + (format port "ClientPID: ~a~%" + (process-id (daemon-session-client session))) + (format port "ClientCommand:~{ ~a~}~%" + (process-command (daemon-session-client session)))) + +(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) + (define sessions (daemon-sessions)) + + (format port session-rec-type) + (newline port) + (newline port) + (for-each + (lambda (session) + (session-scalars->normalized-record session port) + (for-each + (lambda (lock) (lock->record lock port)) + (daemon-session-locks-held session)) + (newline port)) + sessions) + + (format port child-process-rec-type) + (newline port) + (newline port) + (for-each + (lambda (session) + (for-each + (lambda (process) + (session-key->field session port) + (newline port) + (child-process->normalized-record process port) + (newline port) + (newline port)) + (daemon-session-children session))) + sessions)) + ;;; ;;; Options. @@ -205,7 +282,10 @@ active sessions, and the master 'guix-daemon' process." (exit 0))) (option '(#\V "version") #f #f (lambda args - (show-version-and-exit "guix processes"))))) + (show-version-and-exit "guix processes"))) + (option '("normalize") #f #f + (lambda (opt name arg result) + (alist-cons 'normalize #t result))))) (define (show-help) (display (G_ "Usage: guix processes @@ -216,8 +296,13 @@ List the current Guix sessions and their processes.")) (display (G_ " -V, --version display version information and exit")) (newline) + (display (G_ " + --normalize display results as normalized record sets")) + (newline) (show-bug-report-information)) +(define %default-options '()) + ;;; ;;; Entry point. @@ -227,17 +312,12 @@ List the current Guix sessions and their processes.")) (category plumbing) (synopsis "list currently running sessions") (define options - (args-fold* args %options - (lambda (opt name arg result) - (leave (G_ "~A: unrecognized option~%") name)) - cons - '())) + (parse-command-line args %options (list %default-options))) (with-paginated-output-port port - (for-each (lambda (session) - (daemon-session->recutils session port) - (newline port)) - (daemon-sessions)) + (match (assoc-ref options 'normalize) + (#t (format-normalized port)) + (_ (format-single-record port))) ;; Pass 'R' (instead of 'r') so 'less' correctly estimates line length. #:less-options "FRX")) -- 2.29.1 --=-=-=-- From debbugs-submit-bounces@debbugs.gnu.org Fri Nov 06 18:34:25 2020 Received: (at 44460) by debbugs.gnu.org; 6 Nov 2020 23:34:25 +0000 Received: from localhost ([127.0.0.1]:57594 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kbBFQ-0004m8-IT for submit@debbugs.gnu.org; Fri, 06 Nov 2020 18:34:25 -0500 Received: from mail-pf1-f170.google.com ([209.85.210.170]:34821) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kbBFO-0004lu-9Z for 44460@debbugs.gnu.org; Fri, 06 Nov 2020 18:34:23 -0500 Received: by mail-pf1-f170.google.com with SMTP id g7so2878589pfc.2 for <44460@debbugs.gnu.org>; Fri, 06 Nov 2020 15:34:22 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=asu-edu.20150623.gappssmtp.com; s=20150623; h=from:to:subject:date:message-id:mime-version; bh=6TBqU/FJKpkzZMPJLXaVevTBLWEydoAKWMiknqVQPE4=; b=SneIfqOnQDN6RUwP6rOL5AkRZp9P9cEAHSiC8hL2V8buJJa903Bm++r7Q01+d5kcAk ZLl572HxMWhxcOvh+U3ugLvR7IJLOHvwaRqV1GTstmtz2Il9wri9Uaf+P9l7kwB9+7iB p908IDCnPpEh6gOz2XSkd7lsZJoGAbt09s59zJ51DcwFULEGh4Dtb3rJVI+wtPkqvUA2 RYPO3lttMg0MBtlqhVpRN9j+xstXM6WqiW7fa7HPJN0+UmoBK9tRJG5bwH7U0DBaZ/Y0 eb7TK3aGX4xJ+XDqCaWYfEuz7+4mOBXFzF5J1Rmu8/MUbbkZr3Svu/eSdI/ZKSehconl cYZg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:mime-version; bh=6TBqU/FJKpkzZMPJLXaVevTBLWEydoAKWMiknqVQPE4=; b=JYR7R8s1einktqQ5BdidolnW8+qOYpEE9pJm8bHUBu2vMkkro5VXvOZ26be7/XRMxW I4rv8c+/gZAbpLTACjYetvSOTitKoDXwSrJDxhwkVwSOd8gfYmAUvnkK9E2BFUmJvCM5 fIypDC4SD/vPisB6g7wVDvz4OLrPW/j3r1eZ8Sx4mV+dYEXN8NV41rdnUgSsyqXvl0M/ eiE86QsPX7N8OUqeA1iw0Bjx519bnsrmI3keKSfmKjVbzqOYSmQNaflZ3nQu4SfMZhdy 6LSQThXLZTO3FEzWYxmVKvpyKdOr3QW1naPESLB5Etur8KTj9E9syYmz//8AFBBYBnXS sbzw== X-Gm-Message-State: AOAM530hCPjzou1C/oe/EYHUrVwQRoq3ZEVbgPo65hwd0rBRJCl3eAQb 0dB+zSvZ9LIoxCjKDwYcIVc6OORoxIXcoA== X-Google-Smtp-Source: ABdhPJyKp9eIQuACm0dc6VxjWUpn6d3c7RO3xVwtTXKM3jD46K6DYdChgAfPQna9B4REYCq9do3CwQ== X-Received: by 2002:a17:90a:4a95:: with SMTP id f21mr1786296pjh.223.1604705655572; Fri, 06 Nov 2020 15:34:15 -0800 (PST) Received: from ecenter ([2600:1700:83b0:8bd0::7a8]) by smtp.gmail.com with ESMTPSA id b4sm3255622pfi.208.2020.11.06.15.34.14 for <44460@debbugs.gnu.org> (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 06 Nov 2020 15:34:14 -0800 (PST) From: John Soo To: 44460@debbugs.gnu.org Subject: Add copyright lines Date: Fri, 06 Nov 2020 15:34:13 -0800 Message-ID: <878sbeoya2.fsf@asu.edu> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 44460 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) --=-=-= Content-Type: text/plain Sorry, forgot to add my copyright information. - John --=-=-= Content-Type: text/x-patch; charset=utf-8 Content-Disposition: attachment; filename=0001-processes-Optionally-normalize-recutils-output.patch Content-Transfer-Encoding: quoted-printable >From 48945997d9139ddc5e288512de3dda8d5accaf44 Mon Sep 17 00:00:00 2001 From: John Soo Date: Wed, 4 Nov 2020 07:51:52 -0800 Subject: [PATCH] processes: Optionally normalize recutils output. * guix/scripts/processes.scm: Add "normalize" flag --- doc/guix.texi | 27 ++++++++++ guix/scripts/processes.scm | 105 ++++++++++++++++++++++++++++++++----- 2 files changed, 120 insertions(+), 12 deletions(-) diff --git a/doc/guix.texi b/doc/guix.texi index 5e3e0435b4..116706224e 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=C3=A9 Batista@* Copyright @copyright{} 2020 Alexandru-Sergiu Marton@* +Copyright @copyright{} 2020 John Soo@* =20 Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.3 or @@ -12691,6 +12692,32 @@ ClientPID: 19419 ClientCommand: cuirass --cache-directory /var/cache/cuirass @dots{} @end example =20 +Additional options are listed below. + +@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 + @node System Configuration @chapter System Configuration =20 diff --git a/guix/scripts/processes.scm b/guix/scripts/processes.scm index b4ca7b1687..10fda9f223 100644 --- a/guix/scripts/processes.scm +++ b/guix/scripts/processes.scm @@ -1,5 +1,6 @@ ;;; GNU Guix --- Functional package management for GNU ;;; Copyright =C2=A9 2018, 2019, 2020 Ludovic Court=C3=A8s +;;; Copyright =C2=A9 2020 John Soo ;;; ;;; This file is part of GNU Guix. ;;; @@ -176,6 +177,9 @@ active sessions, and the master 'guix-daemon' process." (values (filter-map child-process->session children) master))) =20 +(define (lock->record lock port) + (format port "LockHeld: ~a~%" lock)) + (define (daemon-session->recutils session port) "Display SESSION information in recutils format on PORT." (format port "SessionPID: ~a~%" @@ -184,8 +188,7 @@ active sessions, and the master 'guix-daemon' process." (process-id (daemon-session-client session))) (format port "ClientCommand:~{ ~a~}~%" (process-command (daemon-session-client session))) - (for-each (lambda (lock) - (format port "LockHeld: ~a~%" lock)) + (for-each (lambda (lock) (lock->record lock port)) (daemon-session-locks-held session)) (for-each (lambda (process) (format port "ChildProcess: ~a:~{ ~a~}~%" @@ -193,6 +196,81 @@ active sessions, and the master 'guix-daemon' process." (process-command process))) (daemon-session-children session))) =20 +(define (format-single-record port) + "Display denormalized session information to PORT." + (for-each (lambda (session) + (daemon-session->recutils session port) + (newline port)) + (daemon-sessions))) + +(define session-rec-type + ;; Also includes ClientCommand and LockHeld but it doesn't seem to be + ;; possible to express a plain string field (the default) without further + ;; restrictions + "%rec: Session +%type: PID int +%type: ClientPID int +%key: PID") + +(define child-process-rec-type + ;; Also includes Command but it doesn't seem to be possible to + ;; express a plain string field (the default) without further restrictio= ns + "%rec: ChildProcess +%type: Session rec Session +%type: PID int +%key: PID") + +(define (session-key->field session port) + "Display SESSION PID as field on PORT." + (format + port "Session: ~a" + (process-id (daemon-session-process session)))) + +(define (session-scalars->normalized-record session port) + "Display SESSION scalar fields to PORT in normalized form." + (format port "PID: ~a~%" + (process-id (daemon-session-process session))) + (format port "ClientPID: ~a~%" + (process-id (daemon-session-client session))) + (format port "ClientCommand:~{ ~a~}~%" + (process-command (daemon-session-client session)))) + +(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) + (define sessions (daemon-sessions)) + + (format port session-rec-type) + (newline port) + (newline port) + (for-each + (lambda (session) + (session-scalars->normalized-record session port) + (for-each + (lambda (lock) (lock->record lock port)) + (daemon-session-locks-held session)) + (newline port)) + sessions) + + (format port child-process-rec-type) + (newline port) + (newline port) + (for-each + (lambda (session) + (for-each + (lambda (process) + (session-key->field session port) + (newline port) + (child-process->normalized-record process port) + (newline port) + (newline port)) + (daemon-session-children session))) + sessions)) + ;;; ;;; Options. @@ -205,7 +283,10 @@ active sessions, and the master 'guix-daemon' process." (exit 0))) (option '(#\V "version") #f #f (lambda args - (show-version-and-exit "guix processes"))))) + (show-version-and-exit "guix processes"))) + (option '("normalize") #f #f + (lambda (opt name arg result) + (alist-cons 'normalize #t result))))) =20 (define (show-help) (display (G_ "Usage: guix processes @@ -216,8 +297,13 @@ List the current Guix sessions and their processes.")) (display (G_ " -V, --version display version information and exit")) (newline) + (display (G_ " + --normalize display results as normalized record sets")) + (newline) (show-bug-report-information)) =20 +(define %default-options '()) + ;;; ;;; Entry point. @@ -227,17 +313,12 @@ List the current Guix sessions and their processes.")) (category plumbing) (synopsis "list currently running sessions") (define options - (args-fold* args %options - (lambda (opt name arg result) - (leave (G_ "~A: unrecognized option~%") name)) - cons - '())) + (parse-command-line args %options (list %default-options))) =20 (with-paginated-output-port port - (for-each (lambda (session) - (daemon-session->recutils session port) - (newline port)) - (daemon-sessions)) + (match (assoc-ref options 'normalize) + (#t (format-normalized port)) + (_ (format-single-record port))) =20 ;; Pass 'R' (instead of 'r') so 'less' correctly estimates line length. #:less-options "FRX")) --=20 2.29.1 --=-=-=-- From debbugs-submit-bounces@debbugs.gnu.org Tue Nov 10 17:15:21 2020 Received: (at 44460) by debbugs.gnu.org; 10 Nov 2020 22:15:21 +0000 Received: from localhost ([127.0.0.1]:39256 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kcbv6-0001XW-N2 for submit@debbugs.gnu.org; Tue, 10 Nov 2020 17:15:20 -0500 Received: from eggs.gnu.org ([209.51.188.92]:37546) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kcbv5-0001XH-66 for 44460@debbugs.gnu.org; Tue, 10 Nov 2020 17:15:19 -0500 Received: from fencepost.gnu.org ([2001:470:142:3::e]:42667) by eggs.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kcbuz-0004pg-OV; Tue, 10 Nov 2020 17:15:13 -0500 Received: from [2a01:e0a:1d:7270:af76:b9b:ca24:c465] (port=49796 helo=ribbon) by fencepost.gnu.org with esmtpsa (TLS1.2:RSA_AES_256_CBC_SHA1:256) (Exim 4.82) (envelope-from ) id 1kcbuz-0004tr-27; Tue, 10 Nov 2020 17:15:13 -0500 From: =?utf-8?Q?Ludovic_Court=C3=A8s?= To: John Soo Subject: Re: [bug#44460] Add copyright lines References: <87o8kcv30a.fsf@asu.edu> <878sbeoya2.fsf@asu.edu> Date: Tue, 10 Nov 2020 23:15:11 +0100 In-Reply-To: <878sbeoya2.fsf@asu.edu> (John Soo's message of "Fri, 06 Nov 2020 15:34:13 -0800") Message-ID: <87k0usn9jk.fsf@gnu.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.1 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 44460 Cc: 44460@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) Hi John, John Soo skribis: >>>From 48945997d9139ddc5e288512de3dda8d5accaf44 Mon Sep 17 00:00:00 2001 > From: John Soo > Date: Wed, 4 Nov 2020 07:51:52 -0800 > Subject: [PATCH] processes: Optionally normalize recutils output. > > * guix/scripts/processes.scm: Add "normalize" flag [...] > +@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=E2=80=99d suggest adding a sentence like = =E2=80=9CThe example below lists=E2=80=A6=E2=80=9D (what does it list actually? :-)). In the default format, I wonder if we could already change split =E2=80=98ChildProcess=E2=80=99 into =E2=80=98ChildPID=E2=80=99 and =E2=80= =98ChildCommand=E2=80=99, as you had initially proposed on IRC; would that work? > +(define (lock->record lock port) > + (format port "LockHeld: ~a~%" lock)) Maybe =E2=80=98lock->recutils=E2=80=99 for consistency and to avoid confusi= on with Scheme =E2=80=9Crecords=E2=80=9D? > +(define (format-single-record port) Maybe =E2=80=98daemon-sessions->recutils=E2=80=99? Should =E2=80=98session= s=E2=80=99 be a parameter for clarity? > + "Display denormalized session information to PORT." > + (for-each (lambda (session) > + (daemon-session->recutils session port) > + (newline port)) ^ Indentation is off. > +(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 =E2=80=98sessions=E2=80=99 a paramete= r? > + (define sessions (daemon-sessions)) > + > + (format port session-rec-type) As reported by =E2=80=98-Wformat=E2=80=99, passing a non-literal format str= ing is risky; write this instead: (display session-rec-type port) > + (newline port) > + (newline port) > + (for-each > + (lambda (session) Preferable indent =E2=80=98for-each=E2=80=99 like so: (for-each (lambda (session) Likewise below. > + (display (G_ " > + --normalize display results as normalized record sets")) Should it be =E2=80=98--format=3Dnormalized=E2=80=99 (just like we have =E2= =80=98--format=E2=80=99 in =E2=80=98guix describe=E2=80=99, for instance)? Could you send an updated patch? Thanks! Ludo=E2=80=99. From debbugs-submit-bounces@debbugs.gnu.org Wed Nov 11 12:51:20 2020 Received: (at 44460) by debbugs.gnu.org; 11 Nov 2020 17:51:20 +0000 Received: from localhost ([127.0.0.1]:42752 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kcuH9-0004Xu-9Z for submit@debbugs.gnu.org; Wed, 11 Nov 2020 12:51:19 -0500 Received: from mail-pf1-f175.google.com ([209.85.210.175]:46337) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kcuH7-0004XZ-0J for 44460@debbugs.gnu.org; Wed, 11 Nov 2020 12:51:18 -0500 Received: by mail-pf1-f175.google.com with SMTP id v12so2015332pfm.13 for <44460@debbugs.gnu.org>; Wed, 11 Nov 2020 09:51:16 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=asu-edu.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:references:date:in-reply-to:message-id :user-agent:mime-version; bh=2bWkqLiIHppT1CQxGxRxwFF6pisUgimqOCnP6RbHm18=; b=YEZCsLDSv0jV7uxYoIi+QoSwLwtfWAFrVvpThABCd4LskzdF/OsTM5p4xHYqcG992D 6RNxqOLUwYkPA8IdsvgzKuKq5L1egIFeQuGq5r9Fco89mTJb1p5rcjd3eQXdwMKoB2cO rcc8oV7SDQmx2gfeJ4Ne5CwdsFzRNLS0MRtczqdwG+FX85j4DRV+g9wFCfGn1K4JiTlc zS0tDb7MjGq6BC+h4q8TZEg/FLqzxLyKICrwHl70VQ2Z2b0/cAsw1MetegU/rGjf34AP H8qOngj2sh5A7Ps+f2aLoDSBJyMesydN7g702en9nYntURhoWnS34idtk1cjN7WHp1YV ubHQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:references:date:in-reply-to :message-id:user-agent:mime-version; bh=2bWkqLiIHppT1CQxGxRxwFF6pisUgimqOCnP6RbHm18=; b=ClQaKUoTKwiYRLWmK1OdDo7xEudDf8Rl/LzNEBjFMc6K3TNq5wOgR/kpuuN7igaFvZ /ToZq8nE4PLT0HC6k8iu9Fs66WY7he2l1T1NOlAipdAZIElts6IsjfEmKFDGnUxwRQbs aaj+BU9ouyOs+gL6Z8uUaLoLf7/pj6cMNXlABxeCGyy3/MDLPOF5hZvGSqoY9oFtBlL+ 6WjKnLlMtjwSIIF9aELyjHEjPcs9HF0MADAVmH01wJNRM0EHDrYO44hMQVqmG151e3VD Ws/34oJUDcDDFUdOrWuTzzONuYCcJn8PHW154qaTZaZgeYyH0Dka5OLb7dIp+cin9qhF DDvQ== X-Gm-Message-State: AOAM5312v50FEscw+hyNulYZjmNNHoPh1oZYFI0OeFyZjComSi21eGwv owhppomTTVllZMLBXtxOUJ03sDvtTERrVw== X-Google-Smtp-Source: ABdhPJyQOhsXiRfVcVTbw8WCl+yR9DaCCEDauznEuqbc8n68XOop0A7F9UpaX4Ly7awcAJXXx9fRhw== X-Received: by 2002:a05:6a00:2af:b029:18c:5a65:8e0f with SMTP id q15-20020a056a0002afb029018c5a658e0fmr7223351pfs.41.1605117070750; Wed, 11 Nov 2020 09:51:10 -0800 (PST) Received: from ecenter ([2600:1700:83b0:8bd0::7a8]) by smtp.gmail.com with ESMTPSA id a11sm3308493pfn.125.2020.11.11.09.51.08 (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 11 Nov 2020 09:51:09 -0800 (PST) From: John Soo To: Ludovic =?utf-8?Q?Court=C3=A8s?= Subject: Re: [bug#44460] Add copyright lines References: <87o8kcv30a.fsf@asu.edu> <878sbeoya2.fsf@asu.edu> <87k0usn9jk.fsf@gnu.org> Date: Wed, 11 Nov 2020 09:51:08 -0800 In-Reply-To: <87k0usn9jk.fsf@gnu.org> ("Ludovic =?utf-8?Q?Court=C3=A8s=22'?= =?utf-8?Q?s?= message of "Tue, 10 Nov 2020 23:15:11 +0100") Message-ID: <87imabok8j.fsf@asu.edu> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.1 (gnu/linux) MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Spam-Score: -0.0 (/) X-Debbugs-Envelope-To: 44460 Cc: 44460@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Hello Ludo, Ludovic Court=C3=A8s writes: >> +@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=E2=80=99d suggest adding a sentence lik= e =E2=80=9CThe > example below lists=E2=80=A6=E2=80=9D (what does it list actually? :-)). > > In the default format, I wonder if we could already change split > =E2=80=98ChildProcess=E2=80=99 into =E2=80=98ChildPID=E2=80=99 and =E2=80= =98ChildCommand=E2=80=99, 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. >> +(define (lock->record lock port) >> + (format port "LockHeld: ~a~%" lock)) > > Maybe =E2=80=98lock->recutils=E2=80=99 for consistency and to avoid confu= sion with > Scheme =E2=80=9Crecords=E2=80=9D? Done. >> +(define (format-single-record port) > > Maybe =E2=80=98daemon-sessions->recutils=E2=80=99? Should =E2=80=98sessi= ons=E2=80=99 be a parameter for > clarity? Much better, thank you. I updated the normalized version too. > >> + "Display denormalized session information to PORT." >> + (for-each (lambda (session) >> + (daemon-session->recutils session port) >> + (newline port)) > ^ > Indentation is off. Fixed. >> +(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 =E2=80=98sessions=E2=80=99 a parame= ter? Done. >> + (define sessions (daemon-sessions)) >> + >> + (format port session-rec-type) > > As reported by =E2=80=98-Wformat=E2=80=99, passing a non-literal format s= tring is risky; > write this instead: > > (display session-rec-type port) Done. >> + (newline port) >> + (newline port) >> + (for-each >> + (lambda (session) > > Preferable indent =E2=80=98for-each=E2=80=99 like so: > > (for-each (lambda (session) Done. > Likewise below. > >> + (display (G_ " >> + --normalize display results as normalized record sets")) > > Should it be =E2=80=98--format=3Dnormalized=E2=80=99 (just like we have = =E2=80=98--format=E2=80=99 in > =E2=80=98guix describe=E2=80=99, 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 --=-=-= Content-Type: text/x-patch; charset=utf-8 Content-Disposition: attachment; filename=0001-processes-Optionally-normalize-recutils-output.patch Content-Transfer-Encoding: quoted-printable >From a19828e504288c03c7e17a88ac2a35eb70ab302c Mon Sep 17 00:00:00 2001 From: John Soo Date: Wed, 4 Nov 2020 07:51:52 -0800 Subject: [PATCH] processes: Optionally normalize recutils output. * guix/scripts/processes.scm: Add "normalize" flag --- doc/guix.texi | 29 ++++++++ guix/scripts/processes.scm | 132 +++++++++++++++++++++++++++++++------ 2 files changed, 142 insertions(+), 19 deletions(-) diff --git a/doc/guix.texi b/doc/guix.texi index 5e3e0435b4..5df6096f39 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=C3=A9 Batista@* Copyright @copyright{} 2020 Alexandru-Sergiu Marton@* +Copyright @copyright{} 2020 John Soo@* =20 Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.3 or @@ -12691,6 +12692,34 @@ ClientPID: 19419 ClientCommand: cuirass --cache-directory /var/cache/cuirass @dots{} @end example =20 +Additional options are listed below. + +@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. 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. + +@example +$ guix processes --normalize | \ + 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 + @node System Configuration @chapter System Configuration =20 diff --git a/guix/scripts/processes.scm b/guix/scripts/processes.scm index b4ca7b1687..af1d220774 100644 --- a/guix/scripts/processes.scm +++ b/guix/scripts/processes.scm @@ -1,5 +1,6 @@ ;;; GNU Guix --- Functional package management for GNU ;;; Copyright =C2=A9 2018, 2019, 2020 Ludovic Court=C3=A8s +;;; Copyright =C2=A9 2020 John Soo ;;; ;;; This file is part of GNU Guix. ;;; @@ -176,6 +177,9 @@ active sessions, and the master 'guix-daemon' process." (values (filter-map child-process->session children) master))) =20 +(define (lock->recutils lock port) + (format port "LockHeld: ~a~%" lock)) + (define (daemon-session->recutils session port) "Display SESSION information in recutils format on PORT." (format port "SessionPID: ~a~%" @@ -184,8 +188,7 @@ active sessions, and the master 'guix-daemon' process." (process-id (daemon-session-client session))) (format port "ClientCommand:~{ ~a~}~%" (process-command (daemon-session-client session))) - (for-each (lambda (lock) - (format port "LockHeld: ~a~%" lock)) + (for-each (lambda (lock) (lock->recutils lock port)) (daemon-session-locks-held session)) (for-each (lambda (process) (format port "ChildProcess: ~a:~{ ~a~}~%" @@ -193,19 +196,89 @@ active sessions, and the master 'guix-daemon' process= ." (process-command process))) (daemon-session-children session))) =20 +(define (daemon-sessions->recutils port sessions) + "Display denormalized SESSIONS information to PORT." + (for-each (lambda (session) + (daemon-session->recutils session port) + (newline port)) + sessions)) + +(define session-rec-type + "%rec: Session +%type: PID int +%type: ClientPID int +%key: PID +%mandatory: ClientPID ClientCommand +%allowed: LockHeld") + +(define child-process-rec-type + "%rec: ChildProcess +%type: PID int +%type: Session rec Session +%key: PID +%mandatory: Command") + +(define (session-key->recutils session port) + "Display SESSION PID as a recutils field on PORT." + (format + port "Session: ~a" + (process-id (daemon-session-process session)))) + +(define (session-scalars->normalized-record session port) + "Display SESSION scalar fields to PORT in normalized form." + (format port "PID: ~a~%" + (process-id (daemon-session-process session))) + (format port "ClientPID: ~a~%" + (process-id (daemon-session-client session))) + (format port "ClientCommand:~{ ~a~}~%" + (process-command (daemon-session-client session)))) + +(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 (daemon-sessions->normalized-record port sessions) + "Display SESSIONS recutils on PORT in normalized form" + (display session-rec-type port) + (newline port) + (newline port) + (for-each (lambda (session) + (session-scalars->normalized-record session port) + (for-each (lambda (lock) + (lock->recutils lock port)) + (daemon-session-locks-held session)) + (newline port)) + sessions) + + (display child-process-rec-type port) + (newline port) + (newline port) + (for-each (lambda (session) + (for-each (lambda (process) + (child-process->normalized-record process port) + (newline port) + (session-key->recutils session port) + (newline port) + (newline port)) + (daemon-session-children session))) + sessions)) + ;;; ;;; Options. ;;; =20 -(define %options - (list (option '(#\h "help") #f #f - (lambda args - (show-help) - (exit 0))) - (option '(#\V "version") #f #f - (lambda args - (show-version-and-exit "guix processes"))))) +(define %available-formats + '("recutils" "recutils-normalized")) + +(define (list-formats) + (display (G_ "The available formats are:\n")) + (newline) + (for-each (lambda (f) + (format #t " - ~a~%" f)) + %available-formats)) =20 (define (show-help) (display (G_ "Usage: guix processes @@ -216,8 +289,33 @@ List the current Guix sessions and their processes.")) (display (G_ " -V, --version display version information and exit")) (newline) + (display (G_ " + -f, --format=3DFORMAT display results as normalized record sets")) + (newline) + (display (G_ " + --list-formats display available formats")) (show-bug-report-information)) =20 +(define %options + (list (option '(#\h "help") #f #f + (lambda args + (show-help) + (exit 0))) + (option '(#\V "version") #f #f + (lambda args + (show-version-and-exit "guix processes"))) + (option '(#\f "format") #t #f + (lambda (opt name arg result) + (unless (member arg %available-formats) + (leave (G_ "~a: unsupported output format~%") arg)) + (alist-cons 'format (string->symbol arg) result))) + (option '("list-formats") #f #f + (lambda (opt name arg result) + (list-formats) + (exit 0))))) + +(define %default-options '((format . recutils))) + ;;; ;;; Entry point. @@ -227,17 +325,13 @@ List the current Guix sessions and their processes.")) (category plumbing) (synopsis "list currently running sessions") (define options - (args-fold* args %options - (lambda (opt name arg result) - (leave (G_ "~A: unrecognized option~%") name)) - cons - '())) + (parse-command-line args %options (list %default-options))) =20 (with-paginated-output-port port - (for-each (lambda (session) - (daemon-session->recutils session port) - (newline port)) - (daemon-sessions)) + (match (assoc-ref options 'format) + ('recutils-normalized + (daemon-sessions->normalized-record port (daemon-sessions))) + (_ (daemon-sessions->recutils port (daemon-sessions)))) =20 ;; Pass 'R' (instead of 'r') so 'less' correctly estimates line length. #:less-options "FRX")) --=20 2.29.1 --=-=-=-- From debbugs-submit-bounces@debbugs.gnu.org Wed Nov 11 12:59:45 2020 Received: (at 44460) by debbugs.gnu.org; 11 Nov 2020 17:59:45 +0000 Received: from localhost ([127.0.0.1]:42761 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kcuPI-0004jd-Ug for submit@debbugs.gnu.org; Wed, 11 Nov 2020 12:59:45 -0500 Received: from mail-pg1-f172.google.com ([209.85.215.172]:42413) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kcuPG-0004jN-IQ for 44460@debbugs.gnu.org; Wed, 11 Nov 2020 12:59:43 -0500 Received: by mail-pg1-f172.google.com with SMTP id i13so1876068pgm.9 for <44460@debbugs.gnu.org>; Wed, 11 Nov 2020 09:59:42 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=asu-edu.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:references:date:in-reply-to:message-id :user-agent:mime-version; bh=WefX+e3OsXor0FudUiMvuDgCPVrzMsM5JL5+vUWMZ24=; b=hhy2ARaNUo8NHQOh6JaH2UrYmqcw3XC2e4xLAZ/f5B5T4xlnJ4yW9uXEuB2+O6qYfN O7lh9RzcNLiKjB15xSPLxPQFiU9j/FejBz4JIY7Ltxkk5aCoydZshQLAN+QwBrtKidn8 SXLKYx0eWGxyLtG6+rhEo9BRUaiMoMhy2womhZIy9uYRhQW+xg44W67XCE2aA3moIZ0b Sl77nwWuS4Gfj7ZDUEEydIW32S/QaWzQpLu+APsdoQffNNJJUXuHs/1BeQgdHWzW4Cm5 wGiD45bNEkbTHWau7AU3c6LRuW9VRGO09PkjLshnhHnZnnU7TD3BwQBxSSJ3STD+6F/0 1u9Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:references:date:in-reply-to :message-id:user-agent:mime-version; bh=WefX+e3OsXor0FudUiMvuDgCPVrzMsM5JL5+vUWMZ24=; b=QhV+az9Oe94wVAmdEGZDODY6wqYFchVktprcPXje5y1S+wir/Dje5/qTpZr6MWZT/S yuMA1yr5R499FfbAWVL8HcsNUhasYQMKcwlvmzBMWKA6jKXV4HpU3yIkOXmb2ad3qX3D FKyO4FysT44aFT2yjeyAy339V3GVlZdg9WBPbRJOdYvFGxXhAaUSU8lyDSpSbL7Jrtdg ZE7EpgmrDikJ0Gu18MDUGHRlGq+jSbPmrBe0SMPSEJmACos5Sq48Npo0Lg7MNWaSiFNv lL44TUnH8QFNlIrhZW0dmxSlCgQ84508v9H2wD3k2L6suynpZHnDIHKQaNveR2WvUOF6 PSyw== X-Gm-Message-State: AOAM5319aJUr2oMlnoTnh1wz1T3rRs15i0Hj4Bc3SeX2MbcN2WmrFnLo ktbMMVxX0iIUoqn35TPQ+epo8zp7+SAh+A== X-Google-Smtp-Source: ABdhPJwcjcwJbaF38eGhGrjrAe0/W/Sh3mYouVvV86Mu4jd621y70WumcO8+1dhEkK222K5GZCsq2g== X-Received: by 2002:a63:1849:: with SMTP id 9mr22764316pgy.443.1605117576341; Wed, 11 Nov 2020 09:59:36 -0800 (PST) Received: from ecenter ([2600:1700:83b0:8bd0::7a8]) by smtp.gmail.com with ESMTPSA id l14sm3620825pfd.113.2020.11.11.09.59.35 (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 11 Nov 2020 09:59:35 -0800 (PST) From: John Soo To: Ludovic =?utf-8?Q?Court=C3=A8s?= Subject: Re: [bug#44460] Add copyright lines References: <87o8kcv30a.fsf@asu.edu> <878sbeoya2.fsf@asu.edu> <87k0usn9jk.fsf@gnu.org> <87imabok8j.fsf@asu.edu> Date: Wed, 11 Nov 2020 09:59:34 -0800 In-Reply-To: <87imabok8j.fsf@asu.edu> (John Soo's message of "Wed, 11 Nov 2020 09:51:08 -0800") Message-ID: <87blg3ojuh.fsf@asu.edu> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.1 (gnu/linux) MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Spam-Score: -0.0 (/) X-Debbugs-Envelope-To: 44460 Cc: 44460@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) --=-=-= Content-Type: text/plain I realized I slightly altered the --help format. That is fixed here. Thanks again, John --=-=-= Content-Type: text/x-patch; charset=utf-8 Content-Disposition: attachment; filename=0001-processes-Optionally-normalize-recutils-output.patch Content-Transfer-Encoding: quoted-printable >From 7d03d98ef9e2164723db09c83b1c6973b2ad916e Mon Sep 17 00:00:00 2001 From: John Soo Date: Wed, 4 Nov 2020 07:51:52 -0800 Subject: [PATCH] processes: Optionally normalize recutils output. * guix/scripts/processes.scm: Add "normalize" flag --- doc/guix.texi | 29 ++++++++ guix/scripts/processes.scm | 132 +++++++++++++++++++++++++++++++------ 2 files changed, 142 insertions(+), 19 deletions(-) diff --git a/doc/guix.texi b/doc/guix.texi index 5e3e0435b4..5df6096f39 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=C3=A9 Batista@* Copyright @copyright{} 2020 Alexandru-Sergiu Marton@* +Copyright @copyright{} 2020 John Soo@* =20 Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.3 or @@ -12691,6 +12692,34 @@ ClientPID: 19419 ClientCommand: cuirass --cache-directory /var/cache/cuirass @dots{} @end example =20 +Additional options are listed below. + +@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. 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. + +@example +$ guix processes --normalize | \ + 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 + @node System Configuration @chapter System Configuration =20 diff --git a/guix/scripts/processes.scm b/guix/scripts/processes.scm index b4ca7b1687..02515b1c1d 100644 --- a/guix/scripts/processes.scm +++ b/guix/scripts/processes.scm @@ -1,5 +1,6 @@ ;;; GNU Guix --- Functional package management for GNU ;;; Copyright =C2=A9 2018, 2019, 2020 Ludovic Court=C3=A8s +;;; Copyright =C2=A9 2020 John Soo ;;; ;;; This file is part of GNU Guix. ;;; @@ -176,6 +177,9 @@ active sessions, and the master 'guix-daemon' process." (values (filter-map child-process->session children) master))) =20 +(define (lock->recutils lock port) + (format port "LockHeld: ~a~%" lock)) + (define (daemon-session->recutils session port) "Display SESSION information in recutils format on PORT." (format port "SessionPID: ~a~%" @@ -184,8 +188,7 @@ active sessions, and the master 'guix-daemon' process." (process-id (daemon-session-client session))) (format port "ClientCommand:~{ ~a~}~%" (process-command (daemon-session-client session))) - (for-each (lambda (lock) - (format port "LockHeld: ~a~%" lock)) + (for-each (lambda (lock) (lock->recutils lock port)) (daemon-session-locks-held session)) (for-each (lambda (process) (format port "ChildProcess: ~a:~{ ~a~}~%" @@ -193,19 +196,89 @@ active sessions, and the master 'guix-daemon' process= ." (process-command process))) (daemon-session-children session))) =20 +(define (daemon-sessions->recutils port sessions) + "Display denormalized SESSIONS information to PORT." + (for-each (lambda (session) + (daemon-session->recutils session port) + (newline port)) + sessions)) + +(define session-rec-type + "%rec: Session +%type: PID int +%type: ClientPID int +%key: PID +%mandatory: ClientPID ClientCommand +%allowed: LockHeld") + +(define child-process-rec-type + "%rec: ChildProcess +%type: PID int +%type: Session rec Session +%key: PID +%mandatory: Command") + +(define (session-key->recutils session port) + "Display SESSION PID as a recutils field on PORT." + (format + port "Session: ~a" + (process-id (daemon-session-process session)))) + +(define (session-scalars->normalized-record session port) + "Display SESSION scalar fields to PORT in normalized form." + (format port "PID: ~a~%" + (process-id (daemon-session-process session))) + (format port "ClientPID: ~a~%" + (process-id (daemon-session-client session))) + (format port "ClientCommand:~{ ~a~}~%" + (process-command (daemon-session-client session)))) + +(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 (daemon-sessions->normalized-record port sessions) + "Display SESSIONS recutils on PORT in normalized form" + (display session-rec-type port) + (newline port) + (newline port) + (for-each (lambda (session) + (session-scalars->normalized-record session port) + (for-each (lambda (lock) + (lock->recutils lock port)) + (daemon-session-locks-held session)) + (newline port)) + sessions) + + (display child-process-rec-type port) + (newline port) + (newline port) + (for-each (lambda (session) + (for-each (lambda (process) + (child-process->normalized-record process port) + (newline port) + (session-key->recutils session port) + (newline port) + (newline port)) + (daemon-session-children session))) + sessions)) + ;;; ;;; Options. ;;; =20 -(define %options - (list (option '(#\h "help") #f #f - (lambda args - (show-help) - (exit 0))) - (option '(#\V "version") #f #f - (lambda args - (show-version-and-exit "guix processes"))))) +(define %available-formats + '("recutils" "recutils-normalized")) + +(define (list-formats) + (display (G_ "The available formats are:\n")) + (newline) + (for-each (lambda (f) + (format #t " - ~a~%" f)) + %available-formats)) =20 (define (show-help) (display (G_ "Usage: guix processes @@ -216,8 +289,33 @@ List the current Guix sessions and their processes.")) (display (G_ " -V, --version display version information and exit")) (newline) + (display (G_ " + -f, --format=3DFORMAT display results as normalized record sets")) + (display (G_ " + --list-formats display available formats")) + (newline) (show-bug-report-information)) =20 +(define %options + (list (option '(#\h "help") #f #f + (lambda args + (show-help) + (exit 0))) + (option '(#\V "version") #f #f + (lambda args + (show-version-and-exit "guix processes"))) + (option '(#\f "format") #t #f + (lambda (opt name arg result) + (unless (member arg %available-formats) + (leave (G_ "~a: unsupported output format~%") arg)) + (alist-cons 'format (string->symbol arg) result))) + (option '("list-formats") #f #f + (lambda (opt name arg result) + (list-formats) + (exit 0))))) + +(define %default-options '((format . recutils))) + ;;; ;;; Entry point. @@ -227,17 +325,13 @@ List the current Guix sessions and their processes.")) (category plumbing) (synopsis "list currently running sessions") (define options - (args-fold* args %options - (lambda (opt name arg result) - (leave (G_ "~A: unrecognized option~%") name)) - cons - '())) + (parse-command-line args %options (list %default-options))) =20 (with-paginated-output-port port - (for-each (lambda (session) - (daemon-session->recutils session port) - (newline port)) - (daemon-sessions)) + (match (assoc-ref options 'format) + ('recutils-normalized + (daemon-sessions->normalized-record port (daemon-sessions))) + (_ (daemon-sessions->recutils port (daemon-sessions)))) =20 ;; Pass 'R' (instead of 'r') so 'less' correctly estimates line length. #:less-options "FRX")) --=20 2.29.1 --=-=-=-- From debbugs-submit-bounces@debbugs.gnu.org Wed Nov 11 13:47:49 2020 Received: (at 44460) by debbugs.gnu.org; 11 Nov 2020 18:47:49 +0000 Received: from localhost ([127.0.0.1]:42841 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kcv9p-0005tZ-8D for submit@debbugs.gnu.org; Wed, 11 Nov 2020 13:47:49 -0500 Received: from mail-pl1-f180.google.com ([209.85.214.180]:40785) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kcv9n-0005tK-Ng for 44460@debbugs.gnu.org; Wed, 11 Nov 2020 13:47:48 -0500 Received: by mail-pl1-f180.google.com with SMTP id j5so1428287plk.7 for <44460@debbugs.gnu.org>; Wed, 11 Nov 2020 10:47:47 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=asu-edu.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:references:date:in-reply-to:message-id :user-agent:mime-version; bh=215ukSSHYrZV7ucb7ZXIvmRnsxjJpm1QOrKlpsctBd8=; b=Odrb7k1mS2tn8BtXgc5cGFq7XpKuEEQrGVfTwLDFtctrrkFS0DBlG10796mr0qIaQl V8duxvXeWmL6q3gEKvrv+iLMBSbPvIYTwGzGQu397+4RF18PUDRHCxyKG+E86B6rAss1 xCfiDjBu2eIV61n/fnNmDVo5m9OGOATTTwzym4JLDLAq6dxO2tteK2iUqVPCqAzN9/x1 q86RGhkc/puUzrLWpIua8VvK48zNdxo31yrC78FqEH2Lm6VP6Vo4GOrGpSl8J8mYg246 VYAfNKiyIozsuWr7gNLHdevvSokvu5VdWZ0vF9wXMxMYX3jjjygAjFg8fj0Lfl9OM/Xh hNSg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:references:date:in-reply-to :message-id:user-agent:mime-version; bh=215ukSSHYrZV7ucb7ZXIvmRnsxjJpm1QOrKlpsctBd8=; b=OE5HLvRu5br7lTrfjSCPbiHzFtebGRKW77lVuNxOWvivCpc5dDdn2ZzLgPOSWWWjUl aLVLfvin8GLccHqjqSzmeQhZBbfA3xu+fSUdkqcUUzLOfwVRk8FvJOqwaUbdTpzh/sMJ KJCvyIR0opDjsJZfwBOaCf8GAoQdQ1I3DzrI3zhGrsD5k5A4InqbdC+9mn2H5BslYUuo jybJxDH0FARelvytWdRzOm5sC3CwOc0R/uEee3xFbher7v6cSQs0xIh7O7N7ysrXj4r6 WW9nWvLiVYebdM+40AgXDa0NJ1f2kxFv009ZIV/5kUBoz0SodR9peHAPR5RtkLLpZTx+ 5j7g== X-Gm-Message-State: AOAM53028LghhvGo1VcXLH44ZVSsXgA0yR6OEd3E0CGPNpL+Q56o1GYz SVLD5OnBuAFDC945AVOw3P9CVjIy01Wktw== X-Google-Smtp-Source: ABdhPJz6vFHs8t5szl3ftsjxfBkETbajWd8fIrb1psI4dFrGYChbWnKk4RdC1pkeTXCoJbuMvyufIw== X-Received: by 2002:a17:902:758d:b029:d6:65a6:c70b with SMTP id j13-20020a170902758db02900d665a6c70bmr8804485pll.30.1605120461495; Wed, 11 Nov 2020 10:47:41 -0800 (PST) Received: from ecenter ([2600:1700:83b0:8bd0::7a8]) by smtp.gmail.com with ESMTPSA id h127sm3500462pfe.16.2020.11.11.10.47.40 (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 11 Nov 2020 10:47:40 -0800 (PST) From: John Soo To: Ludovic =?utf-8?Q?Court=C3=A8s?= Subject: Re: [bug#44460] Add copyright lines References: <87o8kcv30a.fsf@asu.edu> <878sbeoya2.fsf@asu.edu> <87k0usn9jk.fsf@gnu.org> <87imabok8j.fsf@asu.edu> <87blg3ojuh.fsf@asu.edu> Date: Wed, 11 Nov 2020 10:47:39 -0800 In-Reply-To: <87blg3ojuh.fsf@asu.edu> (John Soo's message of "Wed, 11 Nov 2020 09:59:34 -0800") Message-ID: <877dqrohmc.fsf@asu.edu> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.1 (gnu/linux) MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 44460 Cc: 44460@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) --=-=-= Content-Type: text/plain Oops! I also forget to change the flag names in the docs and the commit message. Fixing those here. - John --=-=-= Content-Type: text/x-patch; charset=utf-8 Content-Disposition: attachment; filename=0001-processes-Optionally-normalize-recutils-output.patch Content-Transfer-Encoding: quoted-printable >From 6b3bdfcee7644b36f4e70d9f2529af11e7098333 Mon Sep 17 00:00:00 2001 From: John Soo Date: Wed, 4 Nov 2020 07:51:52 -0800 Subject: [PATCH] processes: Optionally normalize recutils output. * guix/scripts/processes.scm: Add "format" and "list-formats" flag --- doc/guix.texi | 39 +++++++++++ guix/scripts/processes.scm | 132 +++++++++++++++++++++++++++++++------ 2 files changed, 152 insertions(+), 19 deletions(-) diff --git a/doc/guix.texi b/doc/guix.texi index 5e3e0435b4..5dc51a1111 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=C3=A9 Batista@* Copyright @copyright{} 2020 Alexandru-Sergiu Marton@* +Copyright @copyright{} 2020 John Soo@* =20 Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.3 or @@ -12691,6 +12692,44 @@ ClientPID: 19419 ClientCommand: cuirass --cache-directory /var/cache/cuirass @dots{} @end example =20 +Additional options are listed below. + +@table @code +@item --format=3D@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 ChildProcess as a field. + +@item recutils-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. + +@example +$ guix processes --format=3Drecutils-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 =20 diff --git a/guix/scripts/processes.scm b/guix/scripts/processes.scm index b4ca7b1687..02515b1c1d 100644 --- a/guix/scripts/processes.scm +++ b/guix/scripts/processes.scm @@ -1,5 +1,6 @@ ;;; GNU Guix --- Functional package management for GNU ;;; Copyright =C2=A9 2018, 2019, 2020 Ludovic Court=C3=A8s +;;; Copyright =C2=A9 2020 John Soo ;;; ;;; This file is part of GNU Guix. ;;; @@ -176,6 +177,9 @@ active sessions, and the master 'guix-daemon' process." (values (filter-map child-process->session children) master))) =20 +(define (lock->recutils lock port) + (format port "LockHeld: ~a~%" lock)) + (define (daemon-session->recutils session port) "Display SESSION information in recutils format on PORT." (format port "SessionPID: ~a~%" @@ -184,8 +188,7 @@ active sessions, and the master 'guix-daemon' process." (process-id (daemon-session-client session))) (format port "ClientCommand:~{ ~a~}~%" (process-command (daemon-session-client session))) - (for-each (lambda (lock) - (format port "LockHeld: ~a~%" lock)) + (for-each (lambda (lock) (lock->recutils lock port)) (daemon-session-locks-held session)) (for-each (lambda (process) (format port "ChildProcess: ~a:~{ ~a~}~%" @@ -193,19 +196,89 @@ active sessions, and the master 'guix-daemon' process= ." (process-command process))) (daemon-session-children session))) =20 +(define (daemon-sessions->recutils port sessions) + "Display denormalized SESSIONS information to PORT." + (for-each (lambda (session) + (daemon-session->recutils session port) + (newline port)) + sessions)) + +(define session-rec-type + "%rec: Session +%type: PID int +%type: ClientPID int +%key: PID +%mandatory: ClientPID ClientCommand +%allowed: LockHeld") + +(define child-process-rec-type + "%rec: ChildProcess +%type: PID int +%type: Session rec Session +%key: PID +%mandatory: Command") + +(define (session-key->recutils session port) + "Display SESSION PID as a recutils field on PORT." + (format + port "Session: ~a" + (process-id (daemon-session-process session)))) + +(define (session-scalars->normalized-record session port) + "Display SESSION scalar fields to PORT in normalized form." + (format port "PID: ~a~%" + (process-id (daemon-session-process session))) + (format port "ClientPID: ~a~%" + (process-id (daemon-session-client session))) + (format port "ClientCommand:~{ ~a~}~%" + (process-command (daemon-session-client session)))) + +(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 (daemon-sessions->normalized-record port sessions) + "Display SESSIONS recutils on PORT in normalized form" + (display session-rec-type port) + (newline port) + (newline port) + (for-each (lambda (session) + (session-scalars->normalized-record session port) + (for-each (lambda (lock) + (lock->recutils lock port)) + (daemon-session-locks-held session)) + (newline port)) + sessions) + + (display child-process-rec-type port) + (newline port) + (newline port) + (for-each (lambda (session) + (for-each (lambda (process) + (child-process->normalized-record process port) + (newline port) + (session-key->recutils session port) + (newline port) + (newline port)) + (daemon-session-children session))) + sessions)) + ;;; ;;; Options. ;;; =20 -(define %options - (list (option '(#\h "help") #f #f - (lambda args - (show-help) - (exit 0))) - (option '(#\V "version") #f #f - (lambda args - (show-version-and-exit "guix processes"))))) +(define %available-formats + '("recutils" "recutils-normalized")) + +(define (list-formats) + (display (G_ "The available formats are:\n")) + (newline) + (for-each (lambda (f) + (format #t " - ~a~%" f)) + %available-formats)) =20 (define (show-help) (display (G_ "Usage: guix processes @@ -216,8 +289,33 @@ List the current Guix sessions and their processes.")) (display (G_ " -V, --version display version information and exit")) (newline) + (display (G_ " + -f, --format=3DFORMAT display results as normalized record sets")) + (display (G_ " + --list-formats display available formats")) + (newline) (show-bug-report-information)) =20 +(define %options + (list (option '(#\h "help") #f #f + (lambda args + (show-help) + (exit 0))) + (option '(#\V "version") #f #f + (lambda args + (show-version-and-exit "guix processes"))) + (option '(#\f "format") #t #f + (lambda (opt name arg result) + (unless (member arg %available-formats) + (leave (G_ "~a: unsupported output format~%") arg)) + (alist-cons 'format (string->symbol arg) result))) + (option '("list-formats") #f #f + (lambda (opt name arg result) + (list-formats) + (exit 0))))) + +(define %default-options '((format . recutils))) + ;;; ;;; Entry point. @@ -227,17 +325,13 @@ List the current Guix sessions and their processes.")) (category plumbing) (synopsis "list currently running sessions") (define options - (args-fold* args %options - (lambda (opt name arg result) - (leave (G_ "~A: unrecognized option~%") name)) - cons - '())) + (parse-command-line args %options (list %default-options))) =20 (with-paginated-output-port port - (for-each (lambda (session) - (daemon-session->recutils session port) - (newline port)) - (daemon-sessions)) + (match (assoc-ref options 'format) + ('recutils-normalized + (daemon-sessions->normalized-record port (daemon-sessions))) + (_ (daemon-sessions->recutils port (daemon-sessions)))) =20 ;; Pass 'R' (instead of 'r') so 'less' correctly estimates line length. #:less-options "FRX")) --=20 2.29.1 --=-=-=-- From debbugs-submit-bounces@debbugs.gnu.org Thu Nov 12 05:58:30 2020 Received: (at 44460) by debbugs.gnu.org; 12 Nov 2020 10:58:30 +0000 Received: from localhost ([127.0.0.1]:43786 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kdAJC-0001GP-2m for submit@debbugs.gnu.org; Thu, 12 Nov 2020 05:58:30 -0500 Received: from eggs.gnu.org ([209.51.188.92]:43644) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kdAJ8-0001GB-ED for 44460@debbugs.gnu.org; Thu, 12 Nov 2020 05:58:28 -0500 Received: from fencepost.gnu.org ([2001:470:142:3::e]:50099) by eggs.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kdAJ2-0007pD-Tt; Thu, 12 Nov 2020 05:58:20 -0500 Received: from [2a01:e0a:1d:7270:af76:b9b:ca24:c465] (port=55060 helo=ribbon) by fencepost.gnu.org with esmtpsa (TLS1.2:RSA_AES_256_CBC_SHA1:256) (Exim 4.82) (envelope-from ) id 1kdAJ2-0001If-4l; Thu, 12 Nov 2020 05:58:20 -0500 From: =?utf-8?Q?Ludovic_Court=C3=A8s?= To: John Soo Subject: Re: [bug#44460] Add copyright lines References: <87o8kcv30a.fsf@asu.edu> <878sbeoya2.fsf@asu.edu> <87k0usn9jk.fsf@gnu.org> <87imabok8j.fsf@asu.edu> X-URL: http://www.fdn.fr/~lcourtes/ X-Revolutionary-Date: 22 Brumaire an 229 de la =?utf-8?Q?R=C3=A9volution?= X-PGP-Key-ID: 0x090B11993D9AEBB5 X-PGP-Key: http://www.fdn.fr/~lcourtes/ludovic.asc X-PGP-Fingerprint: 3CE4 6455 8A84 FDC6 9DB4 0CFB 090B 1199 3D9A EBB5 X-OS: x86_64-pc-linux-gnu Date: Thu, 12 Nov 2020 11:58:18 +0100 In-Reply-To: <87imabok8j.fsf@asu.edu> (John Soo's message of "Wed, 11 Nov 2020 09:51:08 -0800") Message-ID: <87ft5elu45.fsf@gnu.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.1 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 44460 Cc: 44460@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) Hi John, John Soo skribis: [...] >>> +Session_PID: 4278 >>> +PID: 4646 >>> +@end example >>> +@end table >> >> Nice! Right above the example, I=E2=80=99d suggest adding a sentence li= ke =E2=80=9CThe >> example below lists=E2=80=A6=E2=80=9D (what does it list actually? :-)). >> >> In the default format, I wonder if we could already change split >> =E2=80=98ChildProcess=E2=80=99 into =E2=80=98ChildPID=E2=80=99 and =E2= =80=98ChildCommand=E2=80=99, 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 =E2=80=9Cnormalized=E2=80=9D mean in this context? > 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=E2=80=99s OK to break compatibility on just these =E2=80=9CChildProcess=E2=80=9D fields. > * 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=E2=80=99ll take a look. Thanks! Ludo=E2=80=99. From debbugs-submit-bounces@debbugs.gnu.org Thu Nov 12 10:37:53 2020 Received: (at 44460) by debbugs.gnu.org; 12 Nov 2020 15:37:53 +0000 Received: from localhost ([127.0.0.1]:45384 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kdEfY-0006Of-Jr for submit@debbugs.gnu.org; Thu, 12 Nov 2020 10:37:53 -0500 Received: from mail-pf1-f175.google.com ([209.85.210.175]:43919) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kdEfT-0006OQ-Ch for 44460@debbugs.gnu.org; Thu, 12 Nov 2020 10:37:50 -0500 Received: by mail-pf1-f175.google.com with SMTP id z3so4842341pfb.10 for <44460@debbugs.gnu.org>; Thu, 12 Nov 2020 07:37:47 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=asu-edu.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:references:date:in-reply-to:message-id :user-agent:mime-version:content-transfer-encoding; bh=+QlHLrytia74Q/ry0fdWukMowPC4XZeJojeyw9/wPlc=; b=TluLqcSbva06Z1Ok6XC5PmbADtu03Mba45qYviNL0nNa7cnR79CfyYH9Nb+GUyI737 JZcE48o4xKnxQo6dvhUiuqNwtBKzOGiGfeReADaJOC/j9FNMqQUhhMK3/N39t+8488ty 1UiJc+N4gROU2HJT6g1peFUpseE9PfJNyfVyri1TkkSW08WM3l66QSqLYVVO2qUmT5HL DybcT7Fa+rCml5gERvgISR8s4MM78GnrfGJV5d4LyP2eDJAjR+r3V2+3ALq/nq5UF8iL KqteGmYrvjSi9T14elHH8f6ELRyhssAYXeingZSjQT/q/NqjRyBCJlY3ELNzoYUW4s/g pSvQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:references:date:in-reply-to :message-id:user-agent:mime-version:content-transfer-encoding; bh=+QlHLrytia74Q/ry0fdWukMowPC4XZeJojeyw9/wPlc=; b=Ebpg5NcUcTZ1Ogm8sUNkK39GTkQRQ4UxO14u6KS/d31+ed9b8xTry675ah/bIrzBv5 0fiJPHx397N1aDUCuR0oe64GSqZlBBLFoioDsNmSiwV06JtTYnX4RWexY+49NAMhMPyV PsgU9cZJjWvYrwD3I+SEPuHHvXcjgvnCt5odl79ttQzHE5d5nKyIhPLSi+Ye+qWsdd4d heSslm0fXnEsEOLmp/fTioQF2mP3XBOJ4DDdVvRtd5X2uAYAsrIaHc+3ydbitrxBGtTz UWbkTRCvzIrM3cIiQ/evyQekIkMLR3PmcjR3qVr2KUrHFaA2WS/BJzy48GhaXNVIrTS6 J6lQ== X-Gm-Message-State: AOAM5321nOXVu6m07L9kJsYbZ/EA1SAuK8fVui1PCTNOo7nGmeVNy8Et fLZn3VQLhD2Jplm9uQAJ7skC4jnWxe+Liw== X-Google-Smtp-Source: ABdhPJwkaGrVYzjIK6zrjk4+Ya9dP3TKCoMS4rp6PznkT1Pw1Cp2F5TW/lNZf0WKMEJc8ihFegJ/eQ== X-Received: by 2002:a17:90a:1345:: with SMTP id y5mr7234158pjf.88.1605195461014; Thu, 12 Nov 2020 07:37:41 -0800 (PST) Received: from ecenter ([2600:1700:83b0:8bd0::7a8]) by smtp.gmail.com with ESMTPSA id i7sm7230622pjj.20.2020.11.12.07.37.39 (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 12 Nov 2020 07:37:40 -0800 (PST) From: John Soo To: Ludovic =?utf-8?Q?Court=C3=A8s?= Subject: Re: [bug#44460] Add copyright lines References: <87o8kcv30a.fsf@asu.edu> <878sbeoya2.fsf@asu.edu> <87k0usn9jk.fsf@gnu.org> <87imabok8j.fsf@asu.edu> <87ft5elu45.fsf@gnu.org> Date: Thu, 12 Nov 2020 07:37:39 -0800 In-Reply-To: <87ft5elu45.fsf@gnu.org> ("Ludovic =?utf-8?Q?Court=C3=A8s=22'?= =?utf-8?Q?s?= message of "Thu, 12 Nov 2020 11:58:18 +0100") Message-ID: <87361eoabg.fsf@asu.edu> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.1 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Spam-Score: -0.0 (/) X-Debbugs-Envelope-To: 44460 Cc: 44460@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) Hi Ludo, Ludovic Court=C3=A8s 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 =E2=80=9Cnormalized=E2=80=9D 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? >> 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=E2=80=99s OK to break compatibility on just these > =E2=80=9CChildProcess=E2=80=9D fields. Ok. Would it be ok if I put that in a separate commit? Thanks again! - John From debbugs-submit-bounces@debbugs.gnu.org Thu Nov 12 15:29:31 2020 Received: (at 44460) by debbugs.gnu.org; 12 Nov 2020 20:29:31 +0000 Received: from localhost ([127.0.0.1]:45735 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kdJDm-0004yv-Vd for submit@debbugs.gnu.org; Thu, 12 Nov 2020 15:29:31 -0500 Received: from eggs.gnu.org ([209.51.188.92]:44932) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kdJDl-0004yi-BJ for 44460@debbugs.gnu.org; Thu, 12 Nov 2020 15:29:30 -0500 Received: from fencepost.gnu.org ([2001:470:142:3::e]:59982) by eggs.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kdJDg-0002Oq-02; Thu, 12 Nov 2020 15:29:24 -0500 Received: from [2a01:e0a:1d:7270:af76:b9b:ca24:c465] (port=58384 helo=ribbon) by fencepost.gnu.org with esmtpsa (TLS1.2:RSA_AES_256_CBC_SHA1:256) (Exim 4.82) (envelope-from ) id 1kdJDd-0003E7-Oo; Thu, 12 Nov 2020 15:29:22 -0500 From: =?utf-8?Q?Ludovic_Court=C3=A8s?= To: John Soo Subject: Re: [bug#44460] Add copyright lines References: <87o8kcv30a.fsf@asu.edu> <878sbeoya2.fsf@asu.edu> <87k0usn9jk.fsf@gnu.org> <87imabok8j.fsf@asu.edu> <87ft5elu45.fsf@gnu.org> <87361eoabg.fsf@asu.edu> X-URL: http://www.fdn.fr/~lcourtes/ X-Revolutionary-Date: 22 Brumaire an 229 de la =?utf-8?Q?R=C3=A9volution?= X-PGP-Key-ID: 0x090B11993D9AEBB5 X-PGP-Key: http://www.fdn.fr/~lcourtes/ludovic.asc X-PGP-Fingerprint: 3CE4 6455 8A84 FDC6 9DB4 0CFB 090B 1199 3D9A EBB5 X-OS: x86_64-pc-linux-gnu Date: Thu, 12 Nov 2020 21:29:19 +0100 In-Reply-To: <87361eoabg.fsf@asu.edu> (John Soo's message of "Thu, 12 Nov 2020 07:37:39 -0800") Message-ID: <871rgyiajk.fsf@gnu.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.1 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 44460 Cc: 44460@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) Hi, John Soo skribis: > Ludovic Court=C3=A8s 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 =E2=80=9Cnormalized=E2=80=9D 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=E2=80=99s not. > An aside - Probably to be entirely honest about normalizing the output, > locks really would be in a separate record set too. Yeah. > 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=E2=80=99s b= oth human- and machine-readable. But here we end up having a specific machine-readable variant. But yeah, maybe that=E2=80=99s unavoidable. >>> 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=E2=80=99s OK to break compatibility on just these >> =E2=80=9CChildProcess=E2=80=9D fields. > > Ok. Would it be ok if I put that in a separate commit? Yes (you mean in addition to =E2=80=98-f normalized=E2=80=99, right?). Thanks, Ludo=E2=80=99. From debbugs-submit-bounces@debbugs.gnu.org Fri Nov 13 00:34:06 2020 Received: (at 44460) by debbugs.gnu.org; 13 Nov 2020 05:34:06 +0000 Received: from localhost ([127.0.0.1]:46439 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kdRin-0007e2-UE for submit@debbugs.gnu.org; Fri, 13 Nov 2020 00:34:06 -0500 Received: from mail-pg1-f178.google.com ([209.85.215.178]:41997) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kdRik-0007dV-1l for 44460@debbugs.gnu.org; Fri, 13 Nov 2020 00:34:04 -0500 Received: by mail-pg1-f178.google.com with SMTP id i13so6188753pgm.9 for <44460@debbugs.gnu.org>; Thu, 12 Nov 2020 21:34:01 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=asu-edu.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:references:date:in-reply-to:message-id :user-agent:mime-version; bh=2nzcpuRH4B7VAFWKFqtmbPZhi1O8Mx8ARekMqjaSyKI=; b=LSZ5qBq9fgM8EhF6YgnsyLaEKrOsu9QAHSLqNexKnXhH3QzptD4CuREhjYA79WfMHY PxEo2rtieu6Ker9kqOR0Y31gVxZGSXttNZQncWtQbALpcewDpMYz2LAz/ZHXSYZCxNvX 0e7hI90y1nHNtDCoY67hIp6h8OLOx+uFdBi4Y1hZwwYPFXYObrGs4yGm/nRmf5pVBdoE bmgJDeef/VyfUFHx0BsNE+5udXKQ4TNK25i9LbZWg9Qz5s7+wzBeIm4UaApXOCDjlZmz toTRKf9myj0CY3+J9bimRI5d03RJE78Pl9+sVaGztFApdZ9LPi5loZdW3IPuopW2vKQ1 9bxQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:references:date:in-reply-to :message-id:user-agent:mime-version; bh=2nzcpuRH4B7VAFWKFqtmbPZhi1O8Mx8ARekMqjaSyKI=; b=MI46t9tpiWhz+KJujZzLEOXONXqUkQYuKC9uLll+WjBZThzajBxrCi4Vvakw01zHzN ReXmdmxsqSOwPqewXSdBDISMwAflr50cbCZ1Bt+d5b0+HwnhnGkjeyBTmV4pGhuItukg KxRnXJRX4lRWZgqH23iM+O5paGcFfRFujcLodzcf2BSK8ObxnuuOBQvhTmrtg/ExDe8k aCZaRamrfTIXbkeT4w7srPiqD/TcB1zrSs4yuu2nN9G4nvWtblAk8er3QnswjRwhNhjl 25ogj65td579dJXG5cD/NyG0jZEpF1B2J8+CYKmOIPpVymCoi/W9ja+gLaiVYBwyIRnk XWOg== X-Gm-Message-State: AOAM5331IM+ldkbN4OWlVZGCJ0FGLn/rxnLQGoxzQnLW5l8ggZEY0MdI zNAims8O6B805zG/PhuwWek6zzYaadRv6A== X-Google-Smtp-Source: ABdhPJw8iRtO2c1BzHSHwTvzK7ABHmaujdxoGAZUdOO9EmbGlDKXG04YpD6YgR5w0+aVhzBc4ctZwA== X-Received: by 2002:a63:5509:: with SMTP id j9mr767280pgb.3.1605245635785; Thu, 12 Nov 2020 21:33:55 -0800 (PST) Received: from ecenter ([2600:1700:83b0:8bd0::7a8]) by smtp.gmail.com with ESMTPSA id e6sm8351075pfn.190.2020.11.12.21.33.53 (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 12 Nov 2020 21:33:54 -0800 (PST) From: John Soo To: Ludovic =?utf-8?Q?Court=C3=A8s?= Subject: Re: [bug#44460] Add copyright lines References: <87o8kcv30a.fsf@asu.edu> <878sbeoya2.fsf@asu.edu> <87k0usn9jk.fsf@gnu.org> <87imabok8j.fsf@asu.edu> <87ft5elu45.fsf@gnu.org> <87361eoabg.fsf@asu.edu> <871rgyiajk.fsf@gnu.org> Date: Thu, 12 Nov 2020 21:33:52 -0800 In-Reply-To: <871rgyiajk.fsf@gnu.org> ("Ludovic =?utf-8?Q?Court=C3=A8s=22'?= =?utf-8?Q?s?= message of "Thu, 12 Nov 2020 21:29:19 +0100") Message-ID: <87pn4hn7lr.fsf@asu.edu> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.1 (gnu/linux) MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 44460 Cc: 44460@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Hi Ludo, Ludovic Court=C3=A8s writes: > Yes it does! Initially I wondered if it was a term used in recutils, > but apparently it=E2=80=99s not. Do you think it is the best term to use? >> 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). >> 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=E2=80=99s= both > human- and machine-readable. But here we end up having a specific > machine-readable variant. But yeah, maybe that=E2=80=99s 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 --- >>>> 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=E2=80=99s OK to break compatibility on just these >>> =E2=80=9CChildProcess=E2=80=9D fields. >> >> Ok. Would it be ok if I put that in a separate commit? > > Yes (you mean in addition to =E2=80=98-f normalized=E2=80=99, right?). I changed ChildProcess: pid: command to ChildPID and ChildCommand in the default in a separate commit. Thanks again, John --=-=-= Content-Type: text/x-patch; charset=utf-8 Content-Disposition: attachment; filename=0001-processes-Put-ChildProcess-and-ChildPID-on-separate-.patch Content-Transfer-Encoding: quoted-printable >From 6082c559d1200e632b3fb45eb0633d28829667a1 Mon Sep 17 00:00:00 2001 From: John Soo 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(-) 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=C3=A9 Batista@* Copyright @copyright{} 2020 Alexandru-Sergiu Marton@* +Copyright @copyright{} 2020 John Soo@* =20 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/cach= e/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 =20 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. =20 -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 Offl= oad -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}). =20 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 =C2=A9 2018, 2019, 2020 Ludovic Court=C3=A8s +;;; Copyright =C2=A9 2020 John Soo ;;; ;;; 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))) =20 --=20 2.29.1 --=-=-= Content-Type: text/x-patch Content-Disposition: attachment; filename=0002-processes-Optionally-normalize-recutils-output.patch >From 81cdc826a89b4f5ee480faa620f3e8f3e12d8979 Mon Sep 17 00:00:00 2001 From: John Soo 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. --- doc/guix.texi | 38 ++++++++++ guix/scripts/processes.scm | 144 ++++++++++++++++++++++++++++++++----- 2 files changed, 163 insertions(+), 19 deletions(-) diff --git a/doc/guix.texi b/doc/guix.texi index e8814c686c..7da24977cc 100644 --- a/doc/guix.texi +++ b/doc/guix.texi @@ -12695,6 +12695,44 @@ 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 ChildProcess as a field. + +@item recutils-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. + +@example +$ guix processes --format=recutils-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 diff --git a/guix/scripts/processes.scm b/guix/scripts/processes.scm index 3a7ea0b89c..bcc541badb 100644 --- a/guix/scripts/processes.scm +++ b/guix/scripts/processes.scm @@ -177,6 +177,9 @@ active sessions, and the master 'guix-daemon' process." (values (filter-map child-process->session children) master))) +(define (lock->recutils lock port) + (format port "LockHeld: ~a~%" lock)) + (define (daemon-session->recutils session port) "Display SESSION information in recutils format on PORT." (format port "SessionPID: ~a~%" @@ -185,8 +188,7 @@ active sessions, and the master 'guix-daemon' process." (process-id (daemon-session-client session))) (format port "ClientCommand:~{ ~a~}~%" (process-command (daemon-session-client session))) - (for-each (lambda (lock) - (format port "LockHeld: ~a~%" lock)) + (for-each (lambda (lock) (lock->recutils lock port)) (daemon-session-locks-held session)) (for-each (lambda (process) (format port "ChildPID: ~a~%" @@ -195,19 +197,102 @@ active sessions, and the master 'guix-daemon' process." (process-command process))) (daemon-session-children session))) +(define (daemon-sessions->recutils port sessions) + "Display denormalized SESSIONS information to PORT." + (for-each (lambda (session) + (daemon-session->recutils session port) + (newline port)) + sessions)) + +(define session-rec-type + "%rec: Session +%type: PID int +%type: ClientPID int +%key: PID +%mandatory: ClientPID ClientCommand") + +(define lock-rec-type + "%rec: Lock +%mandatory: LockHeld +%type: Session rec Session") + +(define child-process-rec-type + "%rec: ChildProcess +%type: PID int +%type: Session rec Session +%key: PID +%mandatory: Command") + +(define (session-key->recutils session port) + "Display SESSION PID as a recutils field on PORT." + (format + port "Session: ~a" + (process-id (daemon-session-process session)))) + +(define (session-scalars->normalized-record session port) + "Display SESSION scalar fields to PORT in normalized form." + (format port "PID: ~a~%" + (process-id (daemon-session-process session))) + (format port "ClientPID: ~a~%" + (process-id (daemon-session-client session))) + (format port "ClientCommand:~{ ~a~}~%" + (process-command (daemon-session-client session)))) + +(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 (daemon-sessions->normalized-record port sessions) + "Display SESSIONS recutils on PORT in normalized form" + (display session-rec-type port) + (newline port) + (newline port) + (for-each (lambda (session) + (session-scalars->normalized-record session port) + (newline port)) + sessions) + + (display lock-rec-type port) + (newline port) + (newline port) + (for-each (lambda (session) + (for-each (lambda (lock) + (lock->recutils "testing testing" port) + (session-key->recutils session port) + (newline port) + (newline port)) + (daemon-session-locks-held session))) + sessions) + + (display child-process-rec-type port) + (newline port) + (newline port) + (for-each (lambda (session) + (for-each (lambda (process) + (child-process->normalized-record process port) + (newline port) + (session-key->recutils session port) + (newline port) + (newline port)) + (daemon-session-children session))) + sessions)) + ;;; ;;; Options. ;;; -(define %options - (list (option '(#\h "help") #f #f - (lambda args - (show-help) - (exit 0))) - (option '(#\V "version") #f #f - (lambda args - (show-version-and-exit "guix processes"))))) +(define %available-formats + '("recutils" "normalized")) + +(define (list-formats) + (display (G_ "The available formats are:\n")) + (newline) + (for-each (lambda (f) + (format #t " - ~a~%" f)) + %available-formats)) (define (show-help) (display (G_ "Usage: guix processes @@ -218,8 +303,33 @@ List the current Guix sessions and their processes.")) (display (G_ " -V, --version display version information and exit")) (newline) + (display (G_ " + -f, --format=FORMAT display results as normalized record sets")) + (display (G_ " + --list-formats display available formats")) + (newline) (show-bug-report-information)) +(define %options + (list (option '(#\h "help") #f #f + (lambda args + (show-help) + (exit 0))) + (option '(#\V "version") #f #f + (lambda args + (show-version-and-exit "guix processes"))) + (option '(#\f "format") #t #f + (lambda (opt name arg result) + (unless (member arg %available-formats) + (leave (G_ "~a: unsupported output format~%") arg)) + (alist-cons 'format (string->symbol arg) result))) + (option '("list-formats") #f #f + (lambda (opt name arg result) + (list-formats) + (exit 0))))) + +(define %default-options '((format . recutils))) + ;;; ;;; Entry point. @@ -229,17 +339,13 @@ List the current Guix sessions and their processes.")) (category plumbing) (synopsis "list currently running sessions") (define options - (args-fold* args %options - (lambda (opt name arg result) - (leave (G_ "~A: unrecognized option~%") name)) - cons - '())) + (parse-command-line args %options (list %default-options))) (with-paginated-output-port port - (for-each (lambda (session) - (daemon-session->recutils session port) - (newline port)) - (daemon-sessions)) + (match (assoc-ref options 'format) + ('normalized + (daemon-sessions->normalized-record port (daemon-sessions))) + (_ (daemon-sessions->recutils port (daemon-sessions)))) ;; Pass 'R' (instead of 'r') so 'less' correctly estimates line length. #:less-options "FRX")) -- 2.29.1 --=-=-=-- From debbugs-submit-bounces@debbugs.gnu.org Fri Nov 13 11:16:41 2020 Received: (at 44460) by debbugs.gnu.org; 13 Nov 2020 16:16:41 +0000 Received: from localhost ([127.0.0.1]:49208 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kdbke-0005VK-Vs for submit@debbugs.gnu.org; Fri, 13 Nov 2020 11:16:41 -0500 Received: from mail-pg1-f169.google.com ([209.85.215.169]:33487) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kdbkc-0005V6-Sc for 44460@debbugs.gnu.org; Fri, 13 Nov 2020 11:16:39 -0500 Received: by mail-pg1-f169.google.com with SMTP id r186so7477686pgr.0 for <44460@debbugs.gnu.org>; Fri, 13 Nov 2020 08:16:38 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=asu-edu.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:references:date:in-reply-to:message-id :user-agent:mime-version; bh=eSnt4I7Y9KF3jyJMnLrB3s3PymPkEVvXX1SBmjHf31o=; b=XuQIMQpb5AUN+cjf6nGZqgMVokvhuVh7z9OLjoRSIo+7xHV/lSVCcRgbpEL+f7mi4Q cSM38E7TYRUB7AHjtXA++Y7F6y5RcSrdtrgnDMSFvyUZPuc/lHgUhFxr+R/iG1ZeZdRO U38ja3Y8VCXQfWh9/awzlPu+bT7jwSmJh9fYsg9mb+Hds4ZMNgyo9jI5lsw8TgXDyRvN DHzS3oNbvnNvP13URF7FmKpq70JJqFV7Q6NvLvYy5anTtHevU3xu8J0pEIdV6QFTosxB hvRF/CKUkOGHVv/emCGOxVnkrgBX+MMohCk3LNDlz7K7FUo9U1WyirIryeZljWsc9mTD vEbA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:references:date:in-reply-to :message-id:user-agent:mime-version; bh=eSnt4I7Y9KF3jyJMnLrB3s3PymPkEVvXX1SBmjHf31o=; b=H5yalPnfz3aPwO/vS1+BRFfSPSDCViVnAIz6fwyPgi3O7YrbqkMNzn4SYFlKQhiQGt lEkd1ZxpJwTdHu9S1N4tvdKuk6JJy++INVzGaw/rU0zl7oWDy8l90fZuA5h6V2GI7nXQ T0d9CIC3qgeLUQzrMpLXrb3VBdWpe3UdczR4pRkuBcdGmqQBPW2jZi8RO9y8BvYbCi09 VpjvMqpWBJYizlQBgI7jXmyPSksRrfZ03JhYojevTLsJ/fcJlpRlrT24ajkplT7ArOan 0x3QvgaETmxF2d8voihYOYbYHc2dku739mXCjzKQLi0DqCVaxa1/o4+ZZEor5wj4vhSV +V/g== X-Gm-Message-State: AOAM532W4DmO0GGUKZpQ9zq9kMQU5ZHsJPLXZqeN2GGzOj/aFKfhYKZO RKTGZx/04bU61sAvM4+Ges26gQiWja490Wfx X-Google-Smtp-Source: ABdhPJykYRAAe5f4qMDJOQ/B8PVLqbXDdjz8MOHPUeN8cZuMSUI1svo/Lp9UEDWAtkwLatnlI4x+Mg== X-Received: by 2002:a17:90a:987:: with SMTP id 7mr3814606pjo.84.1605284187548; Fri, 13 Nov 2020 08:16:27 -0800 (PST) Received: from ecenter ([2600:1700:83b0:8bd0::7a8]) by smtp.gmail.com with ESMTPSA id q14sm8695496pfl.163.2020.11.13.08.16.26 (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 13 Nov 2020 08:16:26 -0800 (PST) From: John Soo To: Ludovic =?utf-8?Q?Court=C3=A8s?= Subject: Re: [bug#44460] Add copyright lines References: <87o8kcv30a.fsf@asu.edu> <878sbeoya2.fsf@asu.edu> <87k0usn9jk.fsf@gnu.org> <87imabok8j.fsf@asu.edu> <87ft5elu45.fsf@gnu.org> <87361eoabg.fsf@asu.edu> <871rgyiajk.fsf@gnu.org> <87pn4hn7lr.fsf@asu.edu> Date: Fri, 13 Nov 2020 08:16:25 -0800 In-Reply-To: <87pn4hn7lr.fsf@asu.edu> (John Soo's message of "Thu, 12 Nov 2020 21:33:52 -0800") Message-ID: <87eekxxmee.fsf@asu.edu> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.1 (gnu/linux) MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 44460 Cc: 44460@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) --=-=-= Content-Type: text/plain Hello again, No big changes here, I just forgot to update the manual again. - John --=-=-= Content-Type: text/x-patch; charset=utf-8 Content-Disposition: attachment; filename=0001-processes-Put-ChildProcess-and-ChildPID-on-separate-.patch Content-Transfer-Encoding: quoted-printable >From 6082c559d1200e632b3fb45eb0633d28829667a1 Mon Sep 17 00:00:00 2001 From: John Soo 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(-) 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=C3=A9 Batista@* Copyright @copyright{} 2020 Alexandru-Sergiu Marton@* +Copyright @copyright{} 2020 John Soo@* =20 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/cach= e/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 =20 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. =20 -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 Offl= oad -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}). =20 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 =C2=A9 2018, 2019, 2020 Ludovic Court=C3=A8s +;;; Copyright =C2=A9 2020 John Soo ;;; ;;; 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))) =20 --=20 2.29.1 --=-=-= Content-Type: text/x-patch Content-Disposition: attachment; filename=0002-processes-Optionally-normalize-recutils-output.patch >From becf3a8fee4aea0a49dde47f5728410b97d94fbf Mon Sep 17 00:00:00 2001 From: John Soo 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. --- doc/guix.texi | 38 ++++++++++ guix/scripts/processes.scm | 144 ++++++++++++++++++++++++++++++++----- 2 files changed, 163 insertions(+), 19 deletions(-) diff --git a/doc/guix.texi b/doc/guix.texi index e8814c686c..d67ccd8acc 100644 --- a/doc/guix.texi +++ b/doc/guix.texi @@ -12695,6 +12695,44 @@ 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 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. + +@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 diff --git a/guix/scripts/processes.scm b/guix/scripts/processes.scm index 3a7ea0b89c..bcc541badb 100644 --- a/guix/scripts/processes.scm +++ b/guix/scripts/processes.scm @@ -177,6 +177,9 @@ active sessions, and the master 'guix-daemon' process." (values (filter-map child-process->session children) master))) +(define (lock->recutils lock port) + (format port "LockHeld: ~a~%" lock)) + (define (daemon-session->recutils session port) "Display SESSION information in recutils format on PORT." (format port "SessionPID: ~a~%" @@ -185,8 +188,7 @@ active sessions, and the master 'guix-daemon' process." (process-id (daemon-session-client session))) (format port "ClientCommand:~{ ~a~}~%" (process-command (daemon-session-client session))) - (for-each (lambda (lock) - (format port "LockHeld: ~a~%" lock)) + (for-each (lambda (lock) (lock->recutils lock port)) (daemon-session-locks-held session)) (for-each (lambda (process) (format port "ChildPID: ~a~%" @@ -195,19 +197,102 @@ active sessions, and the master 'guix-daemon' process." (process-command process))) (daemon-session-children session))) +(define (daemon-sessions->recutils port sessions) + "Display denormalized SESSIONS information to PORT." + (for-each (lambda (session) + (daemon-session->recutils session port) + (newline port)) + sessions)) + +(define session-rec-type + "%rec: Session +%type: PID int +%type: ClientPID int +%key: PID +%mandatory: ClientPID ClientCommand") + +(define lock-rec-type + "%rec: Lock +%mandatory: LockHeld +%type: Session rec Session") + +(define child-process-rec-type + "%rec: ChildProcess +%type: PID int +%type: Session rec Session +%key: PID +%mandatory: Command") + +(define (session-key->recutils session port) + "Display SESSION PID as a recutils field on PORT." + (format + port "Session: ~a" + (process-id (daemon-session-process session)))) + +(define (session-scalars->normalized-record session port) + "Display SESSION scalar fields to PORT in normalized form." + (format port "PID: ~a~%" + (process-id (daemon-session-process session))) + (format port "ClientPID: ~a~%" + (process-id (daemon-session-client session))) + (format port "ClientCommand:~{ ~a~}~%" + (process-command (daemon-session-client session)))) + +(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 (daemon-sessions->normalized-record port sessions) + "Display SESSIONS recutils on PORT in normalized form" + (display session-rec-type port) + (newline port) + (newline port) + (for-each (lambda (session) + (session-scalars->normalized-record session port) + (newline port)) + sessions) + + (display lock-rec-type port) + (newline port) + (newline port) + (for-each (lambda (session) + (for-each (lambda (lock) + (lock->recutils "testing testing" port) + (session-key->recutils session port) + (newline port) + (newline port)) + (daemon-session-locks-held session))) + sessions) + + (display child-process-rec-type port) + (newline port) + (newline port) + (for-each (lambda (session) + (for-each (lambda (process) + (child-process->normalized-record process port) + (newline port) + (session-key->recutils session port) + (newline port) + (newline port)) + (daemon-session-children session))) + sessions)) + ;;; ;;; Options. ;;; -(define %options - (list (option '(#\h "help") #f #f - (lambda args - (show-help) - (exit 0))) - (option '(#\V "version") #f #f - (lambda args - (show-version-and-exit "guix processes"))))) +(define %available-formats + '("recutils" "normalized")) + +(define (list-formats) + (display (G_ "The available formats are:\n")) + (newline) + (for-each (lambda (f) + (format #t " - ~a~%" f)) + %available-formats)) (define (show-help) (display (G_ "Usage: guix processes @@ -218,8 +303,33 @@ List the current Guix sessions and their processes.")) (display (G_ " -V, --version display version information and exit")) (newline) + (display (G_ " + -f, --format=FORMAT display results as normalized record sets")) + (display (G_ " + --list-formats display available formats")) + (newline) (show-bug-report-information)) +(define %options + (list (option '(#\h "help") #f #f + (lambda args + (show-help) + (exit 0))) + (option '(#\V "version") #f #f + (lambda args + (show-version-and-exit "guix processes"))) + (option '(#\f "format") #t #f + (lambda (opt name arg result) + (unless (member arg %available-formats) + (leave (G_ "~a: unsupported output format~%") arg)) + (alist-cons 'format (string->symbol arg) result))) + (option '("list-formats") #f #f + (lambda (opt name arg result) + (list-formats) + (exit 0))))) + +(define %default-options '((format . recutils))) + ;;; ;;; Entry point. @@ -229,17 +339,13 @@ List the current Guix sessions and their processes.")) (category plumbing) (synopsis "list currently running sessions") (define options - (args-fold* args %options - (lambda (opt name arg result) - (leave (G_ "~A: unrecognized option~%") name)) - cons - '())) + (parse-command-line args %options (list %default-options))) (with-paginated-output-port port - (for-each (lambda (session) - (daemon-session->recutils session port) - (newline port)) - (daemon-sessions)) + (match (assoc-ref options 'format) + ('normalized + (daemon-sessions->normalized-record port (daemon-sessions))) + (_ (daemon-sessions->recutils port (daemon-sessions)))) ;; Pass 'R' (instead of 'r') so 'less' correctly estimates line length. #:less-options "FRX")) -- 2.29.1 --=-=-=-- From debbugs-submit-bounces@debbugs.gnu.org Sun Nov 29 17:50:05 2020 Received: (at 44460-done) by debbugs.gnu.org; 29 Nov 2020 22:50:06 +0000 Received: from localhost ([127.0.0.1]:52895 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kjVW9-0002tm-Jq for submit@debbugs.gnu.org; Sun, 29 Nov 2020 17:50:05 -0500 Received: from eggs.gnu.org ([209.51.188.92]:57822) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kjVW7-0002tC-Ra for 44460-done@debbugs.gnu.org; Sun, 29 Nov 2020 17:50:04 -0500 Received: from fencepost.gnu.org ([2001:470:142:3::e]:42569) by eggs.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kjVW2-0002cR-GN; Sun, 29 Nov 2020 17:49:58 -0500 Received: from [2a01:e0a:1d:7270:af76:b9b:ca24:c465] (port=56734 helo=ribbon) by fencepost.gnu.org with esmtpsa (TLS1.2:RSA_AES_256_CBC_SHA1:256) (Exim 4.82) (envelope-from ) id 1kjVW2-0007BE-0i; Sun, 29 Nov 2020 17:49:58 -0500 From: =?utf-8?Q?Ludovic_Court=C3=A8s?= To: John Soo Subject: Re: [bug#44460] Add copyright lines References: <87o8kcv30a.fsf@asu.edu> <878sbeoya2.fsf@asu.edu> <87k0usn9jk.fsf@gnu.org> <87imabok8j.fsf@asu.edu> <87ft5elu45.fsf@gnu.org> <87361eoabg.fsf@asu.edu> <871rgyiajk.fsf@gnu.org> <87pn4hn7lr.fsf@asu.edu> <87eekxxmee.fsf@asu.edu> Date: Sun, 29 Nov 2020 23:49:56 +0100 In-Reply-To: <87eekxxmee.fsf@asu.edu> (John Soo's message of "Fri, 13 Nov 2020 08:16:25 -0800") Message-ID: <87wny3ok17.fsf@gnu.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.1 (gnu/linux) MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 44460-done Cc: 44460-done@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Hi, John Soo skribis: >>>From 6082c559d1200e632b3fb45eb0633d28829667a1 Mon Sep 17 00:00:00 2001 > From: John Soo > 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. >>>From becf3a8fee4aea0a49dde47f5728410b97d94fbf Mon Sep 17 00:00:00 2001 > From: John Soo > 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=E2=80=99. --=-=-= Content-Type: text/x-patch Content-Disposition: inline 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) --=-=-=-- From unknown Tue Jun 17 20:39:03 2025 Received: (at fakecontrol) by fakecontrolmessage; To: internal_control@debbugs.gnu.org From: Debbugs Internal Request Subject: Internal Control Message-Id: bug archived. Date: Mon, 28 Dec 2020 12:24:09 +0000 User-Agent: Fakemail v42.6.9 # This is a fake control message. # # The action: # bug archived. thanks # This fakemail brought to you by your local debbugs # administrator