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

Print full directory name from lsof #3440

Merged
merged 1 commit into from
Jan 9, 2018

Conversation

rmccue
Copy link
Contributor

@rmccue rmccue commented Nov 11, 2017

awk splits lines based on spaces, which causes directory names with spaces to end up in other fields. Using a for loop allows us to print from the 9th field onwards instead of just the 9th field.

Fixes #3439.

awk splits lines based on spaces, which causes directory names with spaces to end up in other fields. Using a for loop allows us to print from the 9th field onwards instead of just the 9th field.
@facebook-github-bot
Copy link

Thank you for your pull request and welcome to our community. We require contributors to sign our Contributor License Agreement, and we don't seem to have you on file. In order for us to review and merge your code, please sign up at https://code.facebook.com/cla. If you are contributing on behalf of someone else (eg your employer), the individual CLA may not be sufficient and your employer may need the corporate CLA signed.

If you have received this in error or have any questions, please contact us at cla@fb.com. Thanks!

@facebook-github-bot
Copy link

Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Facebook open source project. Thanks!

@@ -58,7 +58,7 @@ function getProcessCommand(processId, processDirectory) {

function getDirectoryOfProcessById(processId) {
return execSync(
'lsof -p ' + processId + ' | awk \'$4=="cwd" {print $9}\'',
'lsof -p ' + processId + ' | awk \'$4=="cwd" {for (i=9; i<=NF; i++) printf "%s ", $i}\'',
Copy link
Contributor Author

Choose a reason for hiding this comment

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

(Unfortunately, a for loop appears to be the most efficient way to do this; the alternative is to set fields 1-8 to blank strings, but that'd end up less clear as to the intent.)

@Timer Timer added this to the 1.0.x milestone Dec 8, 2017
@gaearon gaearon modified the milestones: 1.0.x, 1.0.18 Jan 9, 2018
@gaearon
Copy link
Contributor

gaearon commented Jan 9, 2018

I haven't tested but I trust you this works.

@gaearon gaearon merged commit 887fd10 into facebook:master Jan 9, 2018
@rmccue rmccue deleted the print-full-dir-name branch January 10, 2018 14:19
@gaearon gaearon mentioned this pull request Jan 15, 2018
Pavek pushed a commit to Pavek/create-react-app that referenced this pull request Jul 10, 2018
awk splits lines based on spaces, which causes directory names with spaces to end up in other fields. Using a for loop allows us to print from the 9th field onwards instead of just the 9th field.
@lock lock bot locked and limited conversation to collaborators Jan 20, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants