summaryrefslogtreecommitdiff
path: root/mjit_worker.c
diff options
context:
space:
mode:
authorTakashi Kokubun <takashikkbn@gmail.com>2019-07-15 10:38:59 +0900
committerTakashi Kokubun <takashikkbn@gmail.com>2019-07-15 10:39:07 +0900
commitdd4f128ac5fa26e3d8c4d003c770e69f9ed9a91e (patch)
treee977654018a2b135ea624115ef3148b974e50f5e /mjit_worker.c
parenta191009a266e97453971f9b24f750861855aaa7b (diff)
Handle failure of opening a null device
This issue is detected by Coverity Scan.
Diffstat (limited to 'mjit_worker.c')
-rw-r--r--mjit_worker.c10
1 files changed, 7 insertions, 3 deletions
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)
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)
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);