Skip to content
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

unix coreconsole fails in when run via PATH search #4581

Closed
janvorli opened this issue Oct 15, 2015 · 5 comments
Closed

unix coreconsole fails in when run via PATH search #4581

janvorli opened this issue Oct 15, 2015 · 5 comments
Labels
Milestone

Comments

@janvorli
Copy link
Member

CoreConsole uses argv[0] to determine it's location, which causes problems when a coreconsole-based app is on the PATH and is run from shell.

Repro steps:

Create a simple C# app (just something that prints hello world will work, or use an existing test app)
Compile it assemble a coreconsole-based app so that you have a single-folder standalone application
Put that folder on the PATH environment variable
Attempt to run it from while in the directory containing the app => It should work
Change to another directory => It now fails with Could not get full path to current executable: No such file or directory

@janvorli
Copy link
Member Author

It looks like on Linuxes, we can get the full path by calling readlink function with "/proc/self/exe" and on FreeBSD readlink function with "/proc/curproc/file".
For OSX, there seems to be proc_pidpath function that can get a path for a pid.

@stephentoub
Copy link
Member

It looks like on Linuxes, we can get the full path by calling readlink function with "/proc/self/exe" ... For OSX, there seems to be proc_pidpath function that can get a path for a pid.

Yeah, that's what we do in System.Diagnostics.Process in corefx on Linux and OS X:
https://github.com/dotnet/corefx/blob/master/src/System.Diagnostics.Process/src/System/Diagnostics/Process.Linux.cs#L184
and
https://github.com/dotnet/corefx/blob/master/src/System.Diagnostics.Process/src/System/Diagnostics/Process.OSX.cs#L180

@davidfowl
Copy link
Member

It would be great if we could fix this ASAP 😄

@gkhanna79 gkhanna79 self-assigned this Oct 19, 2015
@gkhanna79
Copy link
Member

I am working on a fix - tested on Mac and need to test on Ubuntu.

@davidfowl
Copy link
Member

👍

@gkhanna79 gkhanna79 removed their assignment Feb 1, 2016
@msftgits msftgits transferred this issue from dotnet/coreclr Jan 30, 2020
@msftgits msftgits added this to the 1.0.0-rtm milestone Jan 30, 2020
@ghost ghost locked as resolved and limited conversation to collaborators Jan 4, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

5 participants