From patchwork Fri Jul 19 08:05:56 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Jacopo Mondi X-Patchwork-Id: 1718 Return-Path: Received: from relay10.mail.gandi.net (relay10.mail.gandi.net [217.70.178.230]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id E617860C00 for ; Fri, 19 Jul 2019 10:04:43 +0200 (CEST) Received: from uno.lan (2-224-242-101.ip172.fastwebnet.it [2.224.242.101]) (Authenticated sender: jacopo@jmondi.org) by relay10.mail.gandi.net (Postfix) with ESMTPSA id 5E28C24000F; Fri, 19 Jul 2019 08:04:42 +0000 (UTC) From: Jacopo Mondi To: libcamera-devel@lists.libcamera.org Date: Fri, 19 Jul 2019 10:05:56 +0200 Message-Id: <20190719080556.26785-1-jacopo@jmondi.org> X-Mailer: git-send-email 2.21.0 MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH] libcamera: process: Fail loudly on isolate X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 19 Jul 2019 08:04:44 -0000 Add an error debug message when disassociating part of a process execution context using unshare fails. As this is currently used to isolate a child process which is immediately terminated silently if unshare fails, add a debug printout and propagate up the error code to make the failure more visible. Signed-off-by: Jacopo Mondi Reviewed-by: Kieran Bingham Reviewed-by: Niklas Söderlund Reviewed-by: Paul Elder Reviewed-by: Laurent Pinchart --- src/libcamera/process.cpp | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) -- 2.21.0 diff --git a/src/libcamera/process.cpp b/src/libcamera/process.cpp index 6c41da219f05..ab716a9cd57f 100644 --- a/src/libcamera/process.cpp +++ b/src/libcamera/process.cpp @@ -306,7 +306,15 @@ void Process::closeAllFdsExcept(const std::vector &fds) int Process::isolate() { - return unshare(CLONE_NEWUSER | CLONE_NEWNET); + int ret = unshare(CLONE_NEWUSER | CLONE_NEWNET); + if (ret) { + ret = -errno; + LOG(Process, Error) << "Failed to unshare execution context: " + << strerror(-ret); + return ret; + } + + return 0; } /**