Skip to content

Commit

Permalink
Child event stream uses file descriptor 4
Browse files Browse the repository at this point in the history
Plus some other changes while exploring issues blocking #31
Current issue looks like the file isn't there when it goes to delete it.
There's about a hundred, many are different, but all could feasible be caused by this
  • Loading branch information
JoshCheek committed Aug 1, 2016
1 parent 6839725 commit 1e145e1
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 12 deletions.
18 changes: 10 additions & 8 deletions lib/seeing_is_believing/evaluate_by_moving_files.rb
Original file line number Diff line number Diff line change
Expand Up @@ -75,9 +75,11 @@ def backup_existing_file
end

def set_back_to_initial_conditions
@was_backed_up ?
File.rename(backup_filename, filename) :
if @was_backed_up
File.rename(backup_filename, filename)
else
File.delete(filename)
end
end

def write_program_to_file
Expand All @@ -98,19 +100,19 @@ def evaluate_file
# setup environment variables
env = ENV.to_hash.merge 'SIB_VARIABLES.MARSHAL.B64' =>
[Marshal.dump(
event_stream_fd: child_eventstream.to_i,
event_stream_fd: 4,
max_line_captures: max_line_captures,
num_lines: program.lines.count,
filename: filename
)].pack('m0')

# evaluate the code in a child process
opts = {
child_eventstream => child_eventstream,
in: child_stdin,
out: child_stdout,
err: child_stderr,
pgroup: true, # run it in its own process group so we can SIGINT the whole group
4 => child_eventstream,
in: child_stdin,
out: child_stdout,
err: child_stderr,
pgroup: true, # run it in its own process group so we can SIGINT the whole group
}
child_pid = Kernel.spawn(env, *popen_args, opts)
child_pgid = Process.getpgid(child_pid)
Expand Down
2 changes: 1 addition & 1 deletion lib/seeing_is_believing/hard_core_ensure.rb
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ def invoke_code

def invoke_ensure
return if ensure_invoked
trap 'INT', old_handler
self.ensure_invoked = true
trap 'INT', old_handler
options[:ensure].call
end

Expand Down
6 changes: 3 additions & 3 deletions spec/binary/marker_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,9 @@ def assert_parses(input, regex)

it 'requires prefix and a regex' do
described_class.new prefix: '', regex: //
expect { described_class.new }.to raise_error
expect { described_class.new prefix: '' }.to raise_error
expect { described_class.new regex: // }.to raise_error
expect { described_class.new }.to raise_error ArgumentError
expect { described_class.new prefix: '' }.to raise_error ArgumentError
expect { described_class.new regex: // }.to raise_error ArgumentError
end

it 'stores the prefix and a regex' do
Expand Down

0 comments on commit 1e145e1

Please sign in to comment.