aboutsummaryrefslogtreecommitdiffstats
path: root/app/models/compiler.rb
diff options
context:
space:
mode:
authorKazuki Yamaguchi <k@rhe.jp>2016-01-14 01:16:50 +0900
committerKazuki Yamaguchi <k@rhe.jp>2016-01-14 01:16:50 +0900
commitfe103646e904c06d3118824953bdc0ed7672daa8 (patch)
treea9111f40cc13e031abb7e11038b10c9eb8eeaa54 /app/models/compiler.rb
parent5de15ba8d3d780fdb7a9c53281bd3faac4f08e0e (diff)
downloadpoe-fe103646e904c06d3118824953bdc0ed7672daa8.tar.gz
tempfile encodign
Diffstat (limited to 'app/models/compiler.rb')
-rw-r--r--app/models/compiler.rb8
1 files changed, 4 insertions, 4 deletions
diff --git a/app/models/compiler.rb b/app/models/compiler.rb
index 193e592..cde14d4 100644
--- a/app/models/compiler.rb
+++ b/app/models/compiler.rb
@@ -21,18 +21,18 @@ class Compiler < ApplicationRecord
def run_body(snippet, r)
baseroot = Rails.root.join("playground/base").to_s
env_overlay = Rails.root.join("playground").join(language).join(version).to_s
- sf = Tempfile.open
+ sf = Tempfile.open(encoding: Encoding::BINARY)
sf.write(snippet.code)
sf.fsync
- of = Tempfile.open
- ef = Tempfile.open
+ of = Tempfile.open(encoding: Encoding::BINARY)
+ ef = Tempfile.open(encoding: Encoding::BINARY)
pid = spawn(Rails.root.join("sandbox/safe_runner").to_s, baseroot, env_overlay, sf.path, *Shellwords.split(command_line),
in: :close, # TODO
out: of,
err: ef)
_, pst = Process.waitpid2(pid)
ef.rewind
- err = ef.read.force_encoding(Encoding::BINARY)
+ err = ef.read
if pst.signaled? || pst.exitstatus > 0
result = :errored
status = -1