Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions spec/std/process_spec.cr
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,10 @@ describe Process do
# one finishes at all, nothing was broken by the GC
Process.run(*exit_code_command(0))
end

it "accepts tuple args" do
Process.new({path_search_command[0]}).wait.success?.should be_true
end
end

describe ".new (command + args)" do
Expand Down Expand Up @@ -260,6 +264,10 @@ describe Process do
Process.run?([command]).should be_nil
end
end

it "accepts tuple args" do
Process.run({path_search_command[0]}).success?.should be_true
end
end

describe ".run" do
Expand Down
8 changes: 6 additions & 2 deletions src/crystal/system/unix/process.cr
Original file line number Diff line number Diff line change
Expand Up @@ -310,8 +310,12 @@ struct Crystal::System::Process

def self.prepare_args(args : Enumerable(String)) : {String, LibC::Char**}
pathname = args.first
argv = args.map(&.check_no_null_byte.to_unsafe)
{pathname, argv.to_unsafe}
argv = Pointer(Pointer(UInt8)).malloc(args.size)
args.each_with_index do |arg, i|
argv[i] = arg.check_no_null_byte.to_unsafe
end

{pathname, argv}
end

private def self.execvpe(file, argv, envp)
Expand Down
Loading