Skip to content

Commit

Permalink
Use temporary directory for debug sockets on NIX systems (#4637)
Browse files Browse the repository at this point in the history
Fixes: #4523

This PR stores debug sockets in `/tmp/` or `$TMPDIR` (if set) on Linux & OSX platforms.
  • Loading branch information
valters-tomsons authored Jul 1, 2021
1 parent 8fb5ebe commit 69711c2
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 5 deletions.
10 changes: 10 additions & 0 deletions src/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,16 @@ export function getExtensionPath() {
return extensionPath;
}

export function getUnixTempDirectory(){
let envTmp = process.env.TMPDIR;
if(!envTmp)
{
return "/tmp/";
}

return envTmp;
}

export function isBoolean(obj: any): obj is boolean {
return obj === true || obj === false;
}
Expand Down
11 changes: 6 additions & 5 deletions src/features/dotnetTest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -545,12 +545,13 @@ class DebugEventListener {
this._fileName = fileName;
this._server = server;
this._eventStream = eventStream;
// NOTE: The max pipe name on OSX is fairly small, so this name shouldn't bee too long.
const pipeSuffix = "TestDebugEvents-" + process.pid;

if (os.platform() === 'win32') {
this._pipePath = "\\\\.\\pipe\\Microsoft.VSCode.CSharpExt." + pipeSuffix;
} else {
this._pipePath = path.join(utils.getExtensionPath(), "." + pipeSuffix);
this._pipePath = "\\\\.\\pipe\\Microsoft.VSCode.CSharpExt.TestDebugEvents" + process.pid;
}
else {
let tmpdir = utils.getUnixTempDirectory();
this._pipePath = path.join(tmpdir, "ms-dotnettools.csharp-tde-" + process.pid);
}
}

Expand Down

0 comments on commit 69711c2

Please sign in to comment.