-
-
Notifications
You must be signed in to change notification settings - Fork 925
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add :chdir support for exec
#987
Conversation
Move processExecOptions() to RubyIO.java, since it already has check*Options() already. Do note that we restore working directory after `spawn`.
|
@@ -1761,6 +1761,7 @@ public void setRootFiber(IRubyObject fiber) { | |||
} | |||
|
|||
public void setCurrentDirectory(String dir) { | |||
System.setProperty("user.dir", dir); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It makes sense to set the system property here, but it may not be the best for multi-threaded runtimes.
In that case we need to set system property as appropriate.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fwiw you might want to getPosix().chdir(dir). In non-native mode it will set this property and in native mode it will actually change chdir. I have never quite figured out how safe chdir is in a JVM process though...
When I was looking at this: You have an if (something)\ncontinue. Either make that one-liner or put curlies. I suspect IDE autoformatting.. IRubyObject obj = (IRubyObject) opt;
if (valid.contains(obj.toString())) { These two lines are weird for multiple reasons which I am sure you will immediately realize and correct :) |
Sorry I should have asked the big question in that last comment. How much fear do you have with adding this support? I know one fear is the MVM scenario where changing one dir will affect all other dirs in other VM instances. Is there anything beyond that? |
More thoughts should be given to if and how this should be implemented. Punting past 1.7.5, for sure. |
Is this still valid? |
It is probably still "valid" in the sense that this method needs to exist, but the implementation is faulty for the reasons that Tom raised. Perhaps we can print a message about that. In any case, this PR can be closed. |
Rework the option processing, and add support for
:chdir
. Note that we are only dealing with fire-and-forgetexec
.