From: Brian Candler Date: 2011-03-02T21:56:39+09:00 Subject: Re: exec using sh -c or directly running the command, depending on the system Looks like there was a change in Ruby, where perhaps it now does an optimisation to check for cases where a shell isn't required (e.g. no pipelines or redirection) You could make it consistent by using the multi-argument form of exec, which I believe will bypass the shell in all cases: > --------------------------->8-------------------------------------- > # runned.rb > puts Process.pid > puts Process.ppid > > # runner.rb > def runProcess(cmd) def runProcess(*cmd) > pid = nil > > begin > pid = fork do > exec(cmd) exec(*cmd) > exit 1 > end > rescue Errno::ENOENT > $stderr.puts e > end > return pid > end > > runProcess('ruby "runned.rb"', true) runProcess('/usr/bin/ruby', 'runned.rb') -- Posted via http://www.ruby-forum.com/.