npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

electron-job-addon

v1.0.14

Published

Native addon for Windows Job Objects in Electron

Downloads

90

Readme

Electron Job Addon

Native addon for working with Windows Job Objects from Electron main process.

📁 Project Structure

electron-job-addon/
├── binding.gyp              # node-gyp build configuration
├── package.json             # Dependencies and scripts
├── include/
│   └── JobAddon.h           # C++ header file
├── src/
│   ├── JobAddon.cc          # Job Object implementation
│   └── addon.cc             # Node-API wrapper
├── js/
│   ├── index.js             # JavaScript wrapper
│   └── index.d.ts           # TypeScript definitions
├── prebuilds/               # Prebuilt binaries (included in npm package)
└── examples/
    └── usage.js             # Usage examples

📦 Installation

# Install from npm (prebuilt binary included - no build required!)
npm install electron-job-addon

Note: Prebuilt binary for Electron 41 is included in the npm package. No compilation needed!

🚀 Build from Source (Development Only)

If you need to rebuild the native addon (e.g., for a different Electron version):

# Install dependencies
npm install

# Build native addon
npm run build

# Rebuild (clean + build)
npm run rebuild

# Rebuild for specific Electron version
npm run rebuild:electron

✅ Testing

# Run tests
node test.js

📖 Usage

Basic Example

const { Job, JOB_OBJECT_LIMIT_KILL_ON_JOB_CLOSE } = require("./js/index.js");

// Create Job
const job = new Job();
job.create("MyJob");

// Spawn a process
const { spawn } = require("child_process");
const child = spawn("notepad.exe");

// Add process to Job
job.addProcessById(child.pid);

// Set flag: kill process when Job closes
job.setKillOnJobClose(true);

// Close Job (process will be killed)
job.close();

Managing Multiple Processes

const job = new Job();
job.create();
job.setKillOnJobClose(true);

// Spawn multiple processes
const p1 = spawn("process1.exe");
const p2 = spawn("process2.exe");
const p3 = spawn("process3.exe");

job.addProcessById(p1.pid);
job.addProcessById(p2.pid);
job.addProcessById(p3.pid);

// All 3 processes will be killed when Job closes
job.close();

Using with Flags

const {
  Job,
  JOB_OBJECT_LIMIT_KILL_ON_JOB_CLOSE,
  JOB_OBJECT_LIMIT_DIE_ON_UNHANDLED_EXCEPTION,
} = require("./js/index.js");

const job = new Job();
job.create();

// Combine flags
const flags = JOB_OBJECT_LIMIT_KILL_ON_JOB_CLOSE | JOB_OBJECT_LIMIT_DIE_ON_UNHANDLED_EXCEPTION;

job.setLimitFlags(flags);

📋 API

Job Class

constructor()

Creates a Job-wrapper instance.

create(name?: string): boolean

Creates a Windows Job Object.

  • name - optional Job Object name

close(): boolean

Closes the Job Object.

isValid(): boolean

Checks if the Job Object is valid.

addProcess(handle: number | Buffer): boolean

Adds a process to the Job Object.

  • handle - process PID (number) or HANDLE (Buffer)

addProcessById(pid: number): boolean

Adds a process to the Job Object by PID.

setKillOnJobClose(enable: boolean): boolean

Sets the flag to kill processes when Job closes.

setSilentBreakaway(enable: boolean): boolean

Sets the silent breakaway flag.

setLimitFlags(flags: number): boolean

Sets limit flags (bitmask).

Constants

| Constant | Value | Description | | --------------------------------------------- | ------------ | -------------------------------- | | JOB_OBJECT_LIMIT_KILL_ON_JOB_CLOSE | 0x00000001 | Kill processes when Job closes | | JOB_OBJECT_LIMIT_SILENT_BREAKAWAY_OK | 0x00000002 | Allow silent breakaway | | JOB_OBJECT_LIMIT_BREAKAWAY_OK | 0x00000800 | Allow breakaway from Job | | JOB_OBJECT_LIMIT_PROCESS_MEMORY | 0x00000100 | Process memory limit | | JOB_OBJECT_LIMIT_JOB_MEMORY | 0x00000200 | Job memory limit | | JOB_OBJECT_LIMIT_DIE_ON_UNHANDLED_EXCEPTION | 0x00000400 | Terminate on unhandled exception | | JOB_OBJECT_LIMIT_ACTIVE_PROCESS | 0x00002000 | Active process limit |

🔧 Requirements

  • Windows 10 or higher
  • Node.js 18+
  • Electron 41+
  • Visual Studio Build Tools (C++) — only for building from source

📝 Notes

  1. Windows Only: Job Objects is a Windows technology, the addon will not work on other platforms.

  2. Run as Administrator: Some Job Objects operations may require administrator privileges.

  3. Prebuilt Binary: The npm package includes a prebuilt binary for Electron 41. No compilation is required during installation.

  4. Building from Source: If you need to build for a different Electron version:

    # Rebuild for your current Electron version
    npm run rebuild:electron
    
    # Or manually with prebuild
    npx prebuild --runtime electron --target <ABI_VERSION> --arch x64
  5. Using with Angular + Electron: This addon works in the Electron main process only. For Angular apps in Electron, use IPC to communicate between renderer and main process.

🔗 Links