Details
-
Type:
Bug
-
Status:
Resolved
-
Priority:
Minor
-
Resolution: Fixed
-
Affects Version/s: JRuby 1.5.2
-
Fix Version/s: JRuby 1.7.0.pre2
-
Component/s: Core Classes/Modules
-
Labels:None
-
Environment:Mac OS X Snow Leopard running JRuby via RVM
-
Testcase included:yes
-
Number of attachments :
Description
exec() doesn't actually replace the current process as seen by this code:
p $$
exec('echo $$')
This causes issues when working with things like PID files, since they can point to the wrong process.
I don't see the advantage of having this not work where it can, since I can always run processes normally using system(), ``, IO.popen(), open3, etc.
We originally implemented exec to simply spawn and wait because of the destructive native of a "real" exec call. JRuby is often deployed into servers where there will be other apps running, or even when run as a command-line server (like with the GlassFish or Trinidad gems), any exec calls would wipe out the running server and all instances of JRuby in memory. There are probably cases where we could reasonably do the "real" exec, and we've talked about doing it for a long time (I'm personally a fan of the idea), but we need a good way to delimit where a "real" exec is safe and appropriate, so we don't blow up a multi-instance or multi-app JVM.
This is also complicated by the fact that JRuby normally tries to keep in the same JVM any system/exec/backquote calls that start with "ruby". Because so many applications spawn new Ruby instances by shelling out with the "ruby" command, we special-case such executions. If we did not, "ruby" instead of "jruby" would launch, and those applications would pay a substantial startup cost for spinning a whole new JVM.
I personally feel like exec should "really" exec, but I'm very reluctant to do it across the board. Like "exit" which would take down the whole JVM if we made it a "real" exit, JRuby needs to behave in all typical deployment scenarios. This means not doing things that could destroy the host JVM if it's not ours to destroy. So perhaps this would work:
What do you think?