From 7fee5b53973fb4fe049aa0bc5db58093727bdf30 Mon Sep 17 00:00:00 2001 From: Ludovic Courtès Date: Tue, 18 Oct 2016 23:22:03 +0200 Subject: container: Allow 'container-excursion' to the same namespaces. Before that, 'container-excursion' would call 'setns' even when the target namespace is the one the caller is already in, which would fail. * gnu/build/linux-container.scm (container-excursion): Introduce 'source' and 'target'. Compare the result of 'readlink' on these instead of comparing file descriptors to decide whether to call 'setns'. * tests/containers.scm ("container-excursion, same namespace"): New test. --- tests/containers.scm | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'tests/containers.scm') diff --git a/tests/containers.scm b/tests/containers.scm index bbcff3f51f..698bef3e47 100644 --- a/tests/containers.scm +++ b/tests/containers.scm @@ -162,4 +162,13 @@ (waitpid pid) (zero? result))))))) +(skip-if-unsupported) +(test-equal "container-excursion, same namespaces" + 42 + ;; The parent and child are in the same namespaces. 'container-excursion' + ;; should notice that and avoid calling 'setns' since that would fail. + (container-excursion (getpid) + (lambda () + (primitive-exit 42)))) + (test-end) -- cgit 1.4.1