aboutsummaryrefslogtreecommitdiffstats
path: root/mjit.c
diff options
context:
space:
mode:
authork0kubun <k0kubun@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2018-02-06 16:57:46 +0000
committerk0kubun <k0kubun@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2018-02-06 16:57:46 +0000
commit36991485d4cd2f184d71daa14af301e64f86fdf4 (patch)
treedae2c45e5b8331d9e77fc16cfbbb3a9e4465b3cc /mjit.c
parente31eedbdb8ba4216d520733bd00993579951b59e (diff)
downloadruby-36991485d4cd2f184d71daa14af301e64f86fdf4.tar.gz
mjit.c: make null device portable
for future mswin support git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62266 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'mjit.c')
-rw-r--r--mjit.c9
1 files changed, 8 insertions, 1 deletions
diff --git a/mjit.c b/mjit.c
index 8163d41442..7541be6213 100644
--- a/mjit.c
+++ b/mjit.c
@@ -198,6 +198,8 @@ static char *header_file;
static char *pch_file;
/* Path of "/tmp", which can be changed to $TMP in MinGW. */
static char *tmp_dir;
+/* Portable /dev/null, fetched from file.c */
+static char *null_device;
/* Hash like { 1 => true, 2 => true, ... } whose keys are valid `class_serial`s.
This is used to invalidate obsoleted CALL_CACHE. */
static VALUE valid_class_serials;
@@ -321,7 +323,7 @@ start_process(const char *path, char *const *argv)
#else
{
/* Not calling IO functions between fork and exec for safety */
- FILE *f = fopen("/dev/null", "w");
+ FILE *f = fopen(null_device, "w");
int dev_null = fileno(f);
fclose(f);
@@ -1171,6 +1173,10 @@ mjit_init(struct mjit_options *opts)
else {
tmp_dir = get_string("/tmp");
}
+ {
+ VALUE file_null = rb_const_get(rb_cFile, rb_intern("NULL"));
+ null_device = get_string(StringValuePtr(file_null));
+ }
init_header_filename();
pch_file = get_uniq_filename(0, MJIT_TMP_PREFIX "h", ".h.gch");
@@ -1255,6 +1261,7 @@ mjit_finish(void)
remove(pch_file);
xfree(tmp_dir); tmp_dir = NULL;
+ xfree(null_device); null_device = NULL;
xfree(pch_file); pch_file = NULL;
xfree(header_file); header_file = NULL;