Skip to content

fix: #50 #51#52

Open
Agritite wants to merge 5 commits into
thefrontside:v2from
Agritite:v2
Open

fix: #50 #51#52
Agritite wants to merge 5 commits into
thefrontside:v2from
Agritite:v2

Conversation

@Agritite
Copy link
Copy Markdown

@Agritite Agritite commented Nov 28, 2025

Motivation

fixes #50 #51

Approach

  • set subsystem=windows for process-killer
  • spawn process-killer in js to avoid asar problems
  • since we moved spawn to js, we should also expose options for callers to provide their own process-killer paths to improve compatibility to bundlers like rspack and node-loader
  • I have tested this on an app I'm developing that uses ctrlc-windows

Remarks

I can't run yarn format because it fails with run-p not found, then I see that non of run-p, prettier, and eslint is in package.json, and also there's no eslintrc.yml. I did run yarn format:rs though, but js codes 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.

@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented Nov 28, 2025

⚠️ No Changeset found

Latest commit: 063d431

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

Comment thread index.d.ts
/* tslint:disable */
/* eslint-disable */

/* auto-generated by NAPI-RS */
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't need to stage this because no one uses it anyway

Comment thread lib/index.js
? isArm64
? require("../dist/arm64/ctrlc-windows.node")
: require("../dist/x64/ctrlc-windows.node")
: null;
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bundlers like webpack or rspack won't be able to parse non literal paths in require.

Comment thread lib/index.js
"tried to invoke windows-specific ctrlc on a non-windows platform",
);
error.name = "PlatformError";
throw error;
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

move posix.js here

Comment thread lib/index.js
const processKillerPath = join(__dirname, "..", `dist/${archDistDirName}/process-killer.exe`);
native.ctrlc(pid, processKillerPath);
native.ignoreSignal(true);
execFileSync(processKillerPath, [pid.toString()]);
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment thread src/bin/process-killer.rs
#[cfg(windows)]
fn kill_pid(pid: u32) -> Result<(), Box<dyn Error>> {
unsafe {
FreeConsole();
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

a subsystem:windows program doesn't have a console to begin with

Comment thread src/lib.rs
format!("unable to kill process with pid '{:?}'", pid),
)),
Err(error) => Err(Error::new(Status::GenericFailure, format!("{}", error))),
SetConsoleCtrlHandler(None, ignore);
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the only thing that we can't do in nodejs

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Electron-Builder] windows-ctrlc fails to find process-killer in packaged app

1 participant