Skip to content

Fix current_exe() on DragonFly #35494

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

Closed
wants to merge 1 commit into from
Closed

Fix current_exe() on DragonFly #35494

wants to merge 1 commit into from

Conversation

mneumann
Copy link
Contributor

@mneumann mneumann commented Aug 8, 2016

The method using procfs did only work in case procfs is mounted,
which we cannot expect, especially as procfs is deprecated on
DragonFly. Starting with DragonFly 4.6.1 the sysctl method works
correctly, so try sysctl first, and if it returns a path including
a ":" (which is an invalid path), try to read from procfs before
giving up.

The method using procfs did only work in case procfs is mounted,
which we cannot expect, especially as procfs is deprecated on
DragonFly. Starting with DragonFly 4.6.1 the sysctl method works
correctly, so try sysctl first, and if it returns a path including
a ":" (which is an invalid path), try to read from procfs before
giving up.
@rust-highfive
Copy link
Contributor

r? @alexcrichton

(rust_highfive has picked a reviewer for you, use r? to override)

@alexcrichton
Copy link
Member

@bors: r+ e360f70

@nagisa
Copy link
Member

nagisa commented Aug 8, 2016

I’m not sure detection by checking : is correct. : being an invalid character in paths is filesystem dependent. For example tmpfs will likely support : just fine.

@mneumann
Copy link
Contributor Author

@nagisa: yes, you are right. but Rust uses current_exe() in a way, that it will fail if it contains an ":", because it tries to build up an array of paths separated by ":". Consider what I wrote as a hack. Recent versions of DragonFly do not need this hack anymore. I am also fine with using FreeBSD's version of current_exe and provide a patch for older DragonFly systems within our dports collection.

// the procfs method. We determine an older version by inspecting the returned path. If it contains
// an ":", we try the procfs method.
//
// [1]: https://gitweb.dragonflybsd.org/dragonfly.git/commit/726f7ca07e193db73635e9c4e24e40c96087d6d9
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This line is wider than 100 columns, fails make tidy.

@eddyb
Copy link
Member

eddyb commented Aug 14, 2016

@bors r- pending tidy fix

@alexcrichton
Copy link
Member

Closing due to inactivity, but feel free to resubmit with tidy fixed!

bors added a commit that referenced this pull request Dec 9, 2016
…chton

Fix current_exe() on DragonFly (again)

This is a follow up on [this pull request][1].

Since DragonFly 4.6.1 ([this commit][2]), the ```kern.proc.pathname```
sysctl works correctly, i.e. it does not return paths including a ```:```
(see [here][3]). Use it and don't try to fix old versions of DragonFly!
There are not many DragonFly installations out there that we can't
control and no one is compiling Rust from source. If someone wants to
run Rust on a pre-4.6.1 DragonFly system, the ports system should
provide a patch.

[1]: #35494
[2]: https://gitweb.dragonflybsd.org/dragonfly.git/commit/726f7ca07e193db73635e9c4e24e40c96087d6d9
[3]: https://gist.github.com/mneumann/a2f6b6a0a03935b561d6185872a4b222
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants