fix: #50 #51#52
Conversation
|
| /* tslint:disable */ | ||
| /* eslint-disable */ | ||
|
|
||
| /* auto-generated by NAPI-RS */ |
There was a problem hiding this comment.
Don't need to stage this because no one uses it anyway
| ? isArm64 | ||
| ? require("../dist/arm64/ctrlc-windows.node") | ||
| : require("../dist/x64/ctrlc-windows.node") | ||
| : null; |
There was a problem hiding this comment.
Bundlers like webpack or rspack won't be able to parse non literal paths in require.
| "tried to invoke windows-specific ctrlc on a non-windows platform", | ||
| ); | ||
| error.name = "PlatformError"; | ||
| throw error; |
| const processKillerPath = join(__dirname, "..", `dist/${archDistDirName}/process-killer.exe`); | ||
| native.ctrlc(pid, processKillerPath); | ||
| native.ignoreSignal(true); | ||
| execFileSync(processKillerPath, [pid.toString()]); |
There was a problem hiding this comment.
This can correctly spawn executables in asar therefore fixes #50
see https://www.electronjs.org/docs/latest/tutorial/asar-archives#executing-binaries-inside-asar-archive
| #[cfg(windows)] | ||
| fn kill_pid(pid: u32) -> Result<(), Box<dyn Error>> { | ||
| unsafe { | ||
| FreeConsole(); |
There was a problem hiding this comment.
a subsystem:windows program doesn't have a console to begin with
| format!("unable to kill process with pid '{:?}'", pid), | ||
| )), | ||
| Err(error) => Err(Error::new(Status::GenericFailure, format!("{}", error))), | ||
| SetConsoleCtrlHandler(None, ignore); |
There was a problem hiding this comment.
This is the only thing that we can't do in nodejs
Motivation
fixes #50 #51
Approach
subsystem=windowsforprocess-killerprocess-killerin js to avoid asar problemsspawnto js, we should also expose options for callers to provide their ownprocess-killerpaths to improve compatibility to bundlers likerspackandnode-loaderctrlc-windowsRemarks
I can't run
yarn formatbecause it fails withrun-pnot found, then I see that non ofrun-p,prettier, andeslintis in package.json, and also there's noeslintrc.yml. I did runyarn format:rsthough, butjscodes are not formatted. There's nothing I can do because I don't know what versions you guys use, so I'm afraid you'll need to run those for me.