[lxc-devel] [lxc/master] attach: reset signal mask

brauner on Github lxc-bot at linuxcontainers.org
Sun Oct 7 09:27:28 UTC 2018


A non-text attachment was scrubbed...
Name: not available
Type: text/x-mailbox
Size: 631 bytes
Desc: not available
URL: <http://lists.linuxcontainers.org/pipermail/lxc-devel/attachments/20181007/1bd1aee7/attachment.bin>
-------------- next part --------------
From cda109d9e97a539c6ce34554efd7820f39dd942c Mon Sep 17 00:00:00 2001
From: Christian Brauner <christian.brauner at ubuntu.com>
Date: Sun, 7 Oct 2018 11:21:06 +0200
Subject: [PATCH] attach: reset signal mask

Since we introduced clean exit from the mainloop when SIGTERM is sent we
changed the signal mask of the parent process but we never reset the
signal mask for the actual attached process.

Closes #399.

Fixes: 1349e92e4d23 ("console: exit mainloop on SIGTERM")
Signed-off-by: Christian Brauner <christian.brauner at ubuntu.com>
---
 src/lxc/attach.c | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/src/lxc/attach.c b/src/lxc/attach.c
index 689cef709..d3e6d3497 100644
--- a/src/lxc/attach.c
+++ b/src/lxc/attach.c
@@ -1483,6 +1483,13 @@ int lxc_attach(const char *name, const char *lxcpath,
 	}
 
 	if (pid == 0) {
+		ret = pthread_sigmask(SIG_SETMASK,
+				      &terminal.tty_state->oldmask, NULL);
+		if (ret < 0) {
+			SYSERROR("Failed to reset signal mask");
+			_exit(EXIT_FAILURE);
+		}
+
 		ret = attach_child_main(&payload);
 		if (ret < 0)
 			ERROR("Failed to exec");


More information about the lxc-devel mailing list