Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions src/client/stdio.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,3 +59,12 @@ test("should read messages", async () => {

await client.close();
});

test("should return child process pid", async () => {
const client = new StdioClientTransport(serverParameters);

await client.start();
expect(client.pid).not.toBeNull();
await client.close();
expect(client.pid).toBeNull();
});
9 changes: 9 additions & 0 deletions src/client/stdio.ts
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,15 @@ export class StdioClientTransport implements Transport {
return this._process?.stderr ?? null;
}

/**
* The child process pid spawned by this transport.
*
* This is only available after the transport has been started.
*/
get pid(): number | null {
return this._process?.pid ?? null;
}

private processReadBuffer() {
while (true) {
try {
Expand Down