gustavofabro / deno_kill_port

Deno module that kills the process of an informed port.
MIT License
3 stars 1 forks source link

Does not work for Windows (may be depending on OS language) #8

Open spalberg opened 11 months ago

spalberg commented 11 months ago

When trying to kill a process for windows with the system language set to german, the library does not work.

This seems to be related to the output format of netstat, i.e.:

> netstat -a -n -o | findstr 10350
  TCP    127.0.0.1:10350        0.0.0.0:0              ABHÖREN         1528
  TCP    127.0.0.1:10350        127.0.0.1:63106        HERGESTELLT     1528
  TCP    127.0.0.1:10350        127.0.0.1:63113        HERGESTELLT     1528
  TCP    127.0.0.1:10350        127.0.0.1:63116        HERGESTELLT     1528

which leads this line to evaluate to:

pid === 'ABH�REN' // true

Since windows changes even the output of system utilities like netstat dependent on the system language I'm not sure if the regex is broken everywhere or just for certain languages. Do you have a windows system where the regex works for the netstat output?

I'd also be willing to create a PR with a more resilient regex if this is the case.

gustavofabro commented 11 months ago

Hi Sven, appreciate your feedback, I will need some time to test again in a Windows system, but fell free to contribute with a PR!

spalberg commented 11 months ago

Currently working on the PR, see https://github.com/spalberg/deno_kill_port The tests run locally using linux and windows but somehow not in the CI. Might fix that tomorrow.