Print full directory name from lsof (#3440)

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.
This commit is contained in:
Ryan McCue
2018-01-10 02:07:21 +10:00
committed by Dan Abramov
parent dccc752cac
commit 887fd10ed8

View File

@@ -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}\'',
execOptions
).trim();
}