[PATCH weston 1/3] weston: Set CLOEXEC on stdin

Derek Foreman derekf at osg.samsung.com
Fri Mar 24 14:41:12 UTC 2017


We don't want to leak this into apps launched from the panel.

stdout and stderr are left for now because some things launched
by weston - such as weston-keyboard - share weston's log by
printing to those fds.

I'm singling out stdin because it's never needed by a child process
and because it's value is 0, which makes it easy to accidentally
do bad things to (commit 5c611d933f60f720db98331c9c1c6ed4420f9782)

Signed-off-by: Derek Foreman <derekf at osg.samsung.com>
---
 compositor/main.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/compositor/main.c b/compositor/main.c
index e870dd4a..f8a60e97 100644
--- a/compositor/main.c
+++ b/compositor/main.c
@@ -1800,6 +1800,11 @@ int main(int argc, char *argv[])
 		{ WESTON_OPTION_STRING, "config", 'c', &config_file },
 	};
 
+	if (os_fd_set_cloexec(fileno(stdin))) {
+		printf("Unable to set stdin as close on exec().\n");
+		return EXIT_FAILURE;
+	}
+
 	cmdline = copy_command_line(argc, argv);
 	parse_options(core_options, ARRAY_LENGTH(core_options), &argc, argv);
 
-- 
2.11.0



More information about the wayland-devel mailing list