Fixes #69583#69722
Merged
Tyriar merged 2 commits intomicrosoft:masterfrom Mar 4, 2019
Kedstar99:Fix69583
Merged
Conversation
… get the value of the cwd for the integrated terminal
Tyriar
approved these changes
Mar 4, 2019
Member
Tyriar
left a comment
There was a problem hiding this comment.
@Kedstar99 wow great work! So much better than the approach I suggested 🙂
I made a change to handle err just to be safe (which I don't think should ever happen). I like the recent refactor too moving Windows to the bottom 👍
Contributor
Author
|
Hi @Tyriar , thanks for merging.
Would it make sense to do the same if lsof doesn't work for Mac users? At least that way we can be certain it returns something. I am happy to add another PR for that, but it seems rather unnecessary. |
Member
|
@Kedstar99 I'd say let's leave it as is unless someone complains on mac, seems like it's always built-in. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
FIxes #69583
This patch removes the need to use lsof on linux platforms and instead uses the default readlink function in fs. It then reads directly the symbolic link in /proc. For all Linux based systems this should be fine.
http://man7.org/linux/man-pages/man5/proc.5.html
This approach should also be a lot faster compared to the previous lsof command. It also seems to work even if the user has remounted proc to hidepids.
ie mount -o remount,rw,hidepid=2 /proc
This solution will solve the case when users don't have lsof installed.
For OS X, I have kept the old lsof mechanism as they don't have a /proc directory.
EDIT:
Sorry, just refactored the code to make a little more sense. In this case, only run the commands if it is known to work on the respective platforms, otherwise fallback to just return _initialCwd.