[前][次][番号順一覧][スレッド一覧]

ruby-changes:56536

From: Takashi <ko1@a...>
Date: Mon, 15 Jul 2019 10:39:35 +0900 (JST)
Subject: [ruby-changes:56536] Takashi Kokubun: dd4f128ac5 (master): Handle failure of opening a null device

https://git.ruby-lang.org/ruby.git/commit/?id=dd4f128ac5

From dd4f128ac5fa26e3d8c4d003c770e69f9ed9a91e Mon Sep 17 00:00:00 2001
From: Takashi Kokubun <takashikkbn@g...>
Date: Mon, 15 Jul 2019 10:38:59 +0900
Subject: Handle failure of opening a null device

This issue is detected by Coverity Scan.

diff --git a/mjit_worker.c b/mjit_worker.c
index 27af15b..aeb9446 100644
--- a/mjit_worker.c
+++ b/mjit_worker.c
@@ -548,6 +548,13 @@ COMPILER_WARNING_IGNORED(-Wdeprecated-declarations) https://github.com/ruby/ruby/blob/trunk/mjit_worker.c#L548
 static pid_t
 start_process(const char *abspath, char *const *argv)
 {
+    // Not calling non-async-signal-safe functions between vfork
+    // and execv for safety
+    int dev_null = rb_cloexec_open(ruby_null_device, O_WRONLY, 0);
+    if (dev_null < 0) {
+        verbose(1, "MJIT: Failed to open a null device: %s", strerror(errno));
+        return -1;
+    }
     if (mjit_opts.verbose >= 2) {
         const char *arg;
         fprintf(stderr, "Starting process: %s", abspath);
@@ -556,9 +563,6 @@ start_process(const char *abspath, char *const *argv) https://github.com/ruby/ruby/blob/trunk/mjit_worker.c#L563
         fprintf(stderr, "\n");
     }
 
-    // Not calling non-async-signal-safe functions between vfork
-    // and execv for safety
-    int dev_null = rb_cloexec_open(ruby_null_device, O_WRONLY, 0);
     pid_t pid;
 #ifdef _WIN32
     extern HANDLE rb_w32_start_process(const char *abspath, char *const *argv, int out_fd);
-- 
cgit v0.10.2


--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]