Skip to main content
Version: v2.x.x

Seaching PIDs

Returns processes IDs used by the specified ports and port ranges.

getPIDs​

Returns all processes IDs used by the specified ports.

getPIDs(port: number | number[])

  • Requires lsof for Unix and netstat for Windows.
import { getPIDs } from 'poku';

await getPIDs(4000);
await getPIDs([4000, 4001]);

getPIDs.range​

Returns all processes IDs used by the specified port range.

getPIDs.range(startsAt: number, endsAt: number)

  • Requires lsof for Unix and netstat for Windows.
import { getPIDs } from 'poku';

await getPIDs.range(4000, 4100);

tip

If your environment doesn't include lsof by default:

macOS (Homebrew)

brew install lsof

Debian, Ubuntu, etc.

sudo apt-get install lsof

Arch Linux, etc.

sudo pacman -S lsof

Alpine Linux, etc.

apk add lsof