Ver Fonte

Terminal+HackStudio: Fix leaking PTM fd to child processes

The pseudoterminal *master* fd is not supposed to be inherited,
so make sure to open it with O_CLOEXEC.
Sergey Bugaev há 5 anos atrás
pai
commit
d3504b4f9b

+ 1 - 1
Applications/Terminal/main.cpp

@@ -148,7 +148,7 @@ int main(int argc, char** argv)
     if (chdir(get_current_user_home_path().characters()) < 0)
         perror("chdir");
 
-    int ptm_fd = open("/dev/ptmx", O_RDWR);
+    int ptm_fd = open("/dev/ptmx", O_RDWR | O_CLOEXEC);
     if (ptm_fd < 0) {
         perror("open(ptmx)");
         return 1;

+ 1 - 1
DevTools/HackStudio/TerminalWrapper.cpp

@@ -24,7 +24,7 @@ void TerminalWrapper::run_command(const String& command)
         return;
     }
 
-    int ptm_fd = open("/dev/ptmx", O_RDWR);
+    int ptm_fd = open("/dev/ptmx", O_RDWR | O_CLOEXEC);
     if (ptm_fd < 0) {
         perror("open(ptmx)");
         ASSERT_NOT_REACHED();