Skip to content

Fixes #69583#69722

Merged
Tyriar merged 2 commits intomicrosoft:masterfrom
Kedstar99:Fix69583
Mar 4, 2019
Merged

Fixes #69583#69722
Tyriar merged 2 commits intomicrosoft:masterfrom
Kedstar99:Fix69583

Conversation

@Kedstar99
Copy link
Contributor

@Kedstar99 Kedstar99 commented Mar 3, 2019

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.

Copy link
Member

@Tyriar Tyriar left a comment

Choose a reason for hiding this comment

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

@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 👍

@Tyriar Tyriar added this to the March 2019 milestone Mar 4, 2019
@Tyriar Tyriar merged commit 62a1cd9 into microsoft:master Mar 4, 2019
@Kedstar99 Kedstar99 deleted the Fix69583 branch March 5, 2019 00:57
@Kedstar99
Copy link
Contributor Author

Kedstar99 commented Mar 5, 2019

Hi @Tyriar , thanks for merging.

I made a change to handle err just to be safe (which I don't think should ever happen).

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.

@Tyriar
Copy link
Member

Tyriar commented Mar 5, 2019

@Kedstar99 I'd say let's leave it as is unless someone complains on mac, seems like it's always built-in.

@github-actions github-actions bot locked and limited conversation to collaborators Mar 27, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Split terminal doesn't work

2 participants