guix-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

branch master updated: build: shepherd: Check for container support.


From: guix-commits
Subject: branch master updated: build: shepherd: Check for container support.
Date: Mon, 21 Sep 2020 04:22:42 -0400

This is an automated email from the git hooks/post-receive script.

mothacehe pushed a commit to branch master
in repository guix.

The following commit(s) were added to refs/heads/master by this push:
     new 6453915  build: shepherd: Check for container support.
6453915 is described below

commit 6453915cf7729203ef9552c13cb4528c6f4ed122
Author: Mathieu Othacehe <othacehe@gnu.org>
AuthorDate: Mon Sep 21 10:11:17 2020 +0200

    build: shepherd: Check for container support.
    
    Fixes: <https://issues.guix.gnu.org/43533>.
    
    * gnu/build/shepherd.scm (fork+exec-command/container): Check if containers
    are supported before joining PID namespaces.
---
 gnu/build/shepherd.scm | 16 +++++++++++-----
 1 file changed, 11 insertions(+), 5 deletions(-)

diff --git a/gnu/build/shepherd.scm b/gnu/build/shepherd.scm
index 65141bd..9164628 100644
--- a/gnu/build/shepherd.scm
+++ b/gnu/build/shepherd.scm
@@ -1,5 +1,6 @@
 ;;; GNU Guix --- Functional package management for GNU
 ;;; Copyright © 2017, 2018, 2019, 2020 Ludovic Courtès <ludo@gnu.org>
+;;; Copyright © 2020 Mathieu Othacehe <othacehe@gnu.org>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -196,11 +197,16 @@ namespace, in addition to essential bind-mounts such 
/proc."
                                       #:allow-other-keys
                                       #:rest args)
   "This is a variant of 'fork+exec-command' procedure, that joins the
-namespaces of process PID beforehand."
-  (container-excursion* pid
-    (lambda ()
-      (apply fork+exec-command command
-             (strip-keyword-arguments '(#:pid) args)))))
+namespaces of process PID beforehand.  If there is no support for containers,
+on Hurd systems for instance, fallback to direct forking."
+  (let ((container-support?
+         (file-exists? "/proc/self/ns"))
+        (fork-proc (lambda ()
+                     (apply fork+exec-command command
+                            (strip-keyword-arguments '(#:pid) args)))))
+    (if container-support?
+        (container-excursion* pid fork-proc)
+        (fork-proc))))
 
 ;; Local Variables:
 ;; eval: (put 'container-excursion* 'scheme-indent-function 1)



reply via email to

[Prev in Thread] Current Thread [Next in Thread]