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
Fix Issue 20765 - Can't run processes with relative paths when specif… #7455
Conversation
Thanks for your pull request, @CyberShadow! Bugzilla references
Testing this PR locallyIf you don't have a local development environment setup, you can use Digger to test this PR: dub run digger -- build "master + phobos#7455" |
Maybe the motivation was producing a better error message, or someone saw value in bailing out early when it can be determined early on that the process will fail (which is optimizing for a case that I assume is uncommon). The check could be modified to be: if (any!isDirSeparator(name))
{
if (workDir.length == 0 && !isExecutable(name))
throw new ProcessException(text("Not an executable file: ", name));
} Or it could be removed entirely as you did. |
It is dangerous to make assumptions such as those made by the removed code, because things such as ACLs, virtual filesystems, and not-quite-POSIX systems may cause the result to differ from what is expected. Generally in such cases it is more correct to try the action and handle the outcome, rather than attempt to predict it. |
It looks like the test for this fix uncovered an additional problem on FreeBSD. |
I can't figure out why it's failing on FreeBSD. I tried the following C program: #include <stdio.h>
#include <fcntl.h>
#include <unistd.h>
int main()
{
int fd = open("dir", O_RDONLY);
fchdir(fd);
static const char *argv[] = {"./test.sh", 0};
execve(argv[0], argv, NULL);
} But, it works as expected. @jmdavis perhaps might know? |
It was so the error could be handled in the parent, before the |
bf4881f
to
912b2d1
Compare
Fixed the FreeBSD failure. The cause was embarrassingly mundane - I used |
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.
LGTM. Let the OS handle the error sounds good.
…ying a working directory Remove the dubious check which attempted to duplicate the operating system's behavior.
912b2d1
to
92276d0
Compare
…ying a working directory
Remove the dubious check which attempted to duplicate the operating
system's behavior.