GitShow/sindresorhus/pid-port
sindresorhus

pid-port

Get the ID of the process that uses a certain port

by sindresorhus
Star on GitHubForknpm

JavaScript

151 stars11 forks6 contributorsQuiet · 3mo agoSince 2020v2.1.1MIT

Meet the team

See all 6 on GitHub →
sindresorhus
sindresorhus23 contributions
Richienb
Richienb4 contributions
robhogan
robhogan2 contributions
EhabY
EhabY1 contribution
gengjiawen
gengjiawen1 contribution
zikaari
zikaari1 contribution

Languages

View on GitHub →
JavaScript100%

Commit activity

Last 12 weeks · 0 commits

Full graph →

Community health

4 of 6 standards met

Community profile →
71
✓README✓License✓Contributing✓Code of Conduct○Issue Template○PR Template

Recent fixes

View closed PRs →
guoyangzhen
fix: resolve UDP port PID lookup on WindowsMergedPR

Linked issue Closes #20 Description On Windows, outputs different column counts for TCP vs UDP: TCP: — 5 columns UDP: — 4 columns (no State) The Windows implementation hardcodes , which works for TCP but misses UDP PIDs because returns an empty array for 4-column lines. Fix Added a fallback in : when the initial search from finds no PID and the line has fewer columns than expected, search the last column. This correctly handles UDP lines where the PID is at index 3 instead of 4. The fallback is guarded: Only triggers when (avoiding false matches on very short lines) Only accepts the last column if it's a pure numeric value (), preventing false matches with port numbers in address columns Testing The fix is passive for TCP lines (the primary loop returns the PID before the fallback runs). For UDP lines on Windows, the fallback correctly extracts the PID from the last column.

guoyangzhen · 3mo ago
EhabY
Windows: UDP ports never resolve to a PIDClosedIssue

Problem The Windows implementation hardcodes : This works for TCP lines which have 5 tokens (Proto, Local Address, Foreign Address, State, PID): But UDP is connectionless -there is no State column, so lines have only 4 tokens: scans from onward. With only 4 tokens (indices 0–3), returns and the PID is never found. This is confirmed by Microsoft's docs -the State column only applies to TCP. Libraries like explicitly handle this by reading the last column as PID. Suggested fix Since guarantees PID is always the last field, use that instead of a hardcoded index: Environment v2.0.1 Windows 11, any Windows version

EhabY · 3mo ago
EhabY
Fix Windows UDP ports never resolving to a PIDMergedPR

Windows omits the State column for UDP lines, so they have 4 tokens instead of 5. The hardcoded caused to scan past the end of UDP lines. Lowering it to 3 lets the existing scan loop find the PID in both TCP and UDP rows. Fixes #20

EhabY · 3mo ago
Structured data for AI agents

Repository: sindresorhus/pid-port. Description: Get the ID of the process that uses a certain port Stars: 151, Forks: 11. Primary language: JavaScript. Languages: JavaScript (100%). License: MIT. Latest release: v2.1.1 (3mo ago). Open PRs: 0, open issues: 0. Last activity: 3mo ago. Community health: 71%. Top contributors: sindresorhus, Richienb, robhogan, EhabY, gengjiawen, zikaari.

·@ofershap

Replace github.com with gitshow.dev