GoogleContainerTools/skaffold · error

could not get handle from process: %w

Error message

could not get handle from process: %w

What it means

After the process starts, Start obtains a Win32 process handle (getHandleFromProcess on c.Process) needed to assign the process to the job object; this error wraps a handle-acquisition failure. Without the handle, the process cannot be attached to the kill-on-close job group.

Source

Thrown at pkg/skaffold/kubectl/exec_windows.go:69

		BasicLimitInformation: windows.JOBOBJECT_BASIC_LIMIT_INFORMATION{
			LimitFlags: windows.JOB_OBJECT_LIMIT_KILL_ON_JOB_CLOSE,
		},
	}
	if _, err := windows.SetInformationJobObject(
		handle,
		windows.JobObjectExtendedLimitInformation,
		uintptr(unsafe.Pointer(&info)),
		uint32(unsafe.Sizeof(info))); err != nil {
		return fmt.Errorf("could not set information job object: %w", err)
	}

	if err := c.Cmd.Start(); err != nil {
		return fmt.Errorf("could not start the command: %w", err)
	}

	processHandle, err := getHandleFromProcess(c.Process)
	if err != nil {
		return fmt.Errorf("could not get handle from process: %w", err)
	}

	if err := windows.AssignProcessToJobObject(handle, processHandle); err != nil {
		return fmt.Errorf("could not assign job object: %w", err)
	}

	c.handle = handle
	go func() {
		<-c.ctx.Done()
		c.Terminate()
	}()

	return nil
}

func getHandleFromProcess(p *os.Process) (windows.Handle, error) {
	// os.Process contains an unexported processHandle struct, which contains
	// a `handle uintptr` field.

View on GitHub (pinned to a1189de023)

Solutions

  1. Check why the child exits immediately: run it manually; fix its crash/exit (bad args, missing config)
  2. Inspect the wrapped %w Win32 error for access-denied and run with sufficient privileges
  3. Check antivirus/EDR logs for child-process termination
  4. Retry; if the race on immediate exit is the cause, add retry or detect child exit first
Defensive patterns

Strategy: try-catch

Try / catch

if err := c.Start(); err != nil {
    if strings.Contains(err.Error(), "could not get handle from process") {
        return fmt.Errorf("child exited before handle acquisition (%w); run child manually to see its crash", err)
    }
    return err
}

Prevention

When it happens

Trigger: getHandleFromProcess fails because OpenProcess on the just-started process returns an error — the process exited immediately, or access rights to open the handle were denied.

Common situations: The spawned binary crashes/exits instantly (race: handle opened after exit), restricted token lacking PROCESS_ALL_ACCESS / needed rights, security software terminating the child at spawn.

Related errors


AI-assisted analysis of GoogleContainerTools/skaffold@a1189de023 (2026-09-05). Data as JSON: /api/errors/7ebba8ef022ea723. Report an issue: GitHub.