A
Alex DeCaria
I'm trying to understand the difference between the Kernel.system and
Kernel.exec methods. It was explained in an earlier post that .system
started a new process while keeping the old one running, while .exec
replaced the current process with the new one (if I read it correctly).
I created a simple program called test.rb as follows
put "hello"
gets
puts "bye"
and then called it from another program that was simply
system("ruby test.rb")
or
exec "ruby test.rb"
I then looked at the processes in Task Manager while running the second
program which calls the first. I expected that with system("ruby
test.rb") I would see two ruby processes being run, which indeed
occured.
When I ran the second version with exec "ruby test.rb" there were still
two active Ruby processes being run (I expected only one, since one
process would be replaced by the other).
So, what am I missing? What is the difference between .system and
exec?
--Alex
Kernel.exec methods. It was explained in an earlier post that .system
started a new process while keeping the old one running, while .exec
replaced the current process with the new one (if I read it correctly).
I created a simple program called test.rb as follows
put "hello"
gets
puts "bye"
and then called it from another program that was simply
system("ruby test.rb")
or
exec "ruby test.rb"
I then looked at the processes in Task Manager while running the second
program which calls the first. I expected that with system("ruby
test.rb") I would see two ruby processes being run, which indeed
occured.
When I ran the second version with exec "ruby test.rb" there were still
two active Ruby processes being run (I expected only one, since one
process would be replaced by the other).
So, what am I missing? What is the difference between .system and
exec?
--Alex