wavetermdev/waveterm · error

--pid flag is not supported on Windows

Error message

--pid flag is not supported on Windows

What it means

The `wsh badge` command's --pid option targets the badge by process id, but this mechanism relies on platform support that is absent on Windows. badgeRun explicitly rejects the combination of badgePid > 0 and runtime.GOOS == "windows" with this error.

Source

Thrown at cmd/wsh/cmd/wshcmd-badge.go:51

	badgePid      int
)

func init() {
	rootCmd.AddCommand(badgeCmd)
	badgeCmd.Flags().StringVar(&badgeColor, "color", "", "badge color")
	badgeCmd.Flags().Float64Var(&badgePriority, "priority", 10, "badge priority")
	badgeCmd.Flags().BoolVar(&badgeClear, "clear", false, "clear the badge")
	badgeCmd.Flags().BoolVar(&badgeBeep, "beep", false, "play system bell sound")
	badgeCmd.Flags().IntVar(&badgePid, "pid", 0, "watch a pid and automatically clear the badge when it exits (default priority 5)")
}

func badgeRun(cmd *cobra.Command, args []string) (rtnErr error) {
	defer func() {
		sendActivity("badge", rtnErr == nil)
	}()

	if badgePid > 0 && runtime.GOOS == "windows" {
		return fmt.Errorf("--pid flag is not supported on Windows")
	}
	if badgePid > 0 && !cmd.Flags().Changed("priority") {
		badgePriority = 5
	}

	oref, err := resolveBlockArg()
	if err != nil {
		return fmt.Errorf("resolving block: %v", err)
	}
	if oref.OType != waveobj.OType_Block && oref.OType != waveobj.OType_Tab {
		return fmt.Errorf("badge oref must be a block or tab (got %q)", oref.OType)
	}

	var eventData baseds.BadgeEvent
	eventData.ORef = oref.String()

	if badgeClear {
		eventData.Clear = true

View on GitHub (pinned to a4447c1563)

Solutions

  1. Remove the --pid flag when running on Windows and target a block/tab via the block argument instead.
  2. Gate the flag in scripts: only pass --pid when the OS is not Windows (`if ! windows`).
  3. Use `wsh badge --clear` or resolve the block by other means (resolveBlockArg) on Windows.

Example fix

// before (fails on Windows)
wsh badge --pid 1234 "info"

// after
if [[ "$OSTYPE" != msys* && "$OSTYPE" != cygwin* ]]; then
  wsh badge --pid 1234 "info"
else
  wsh badge --block <blockid> "info"
fi
Defensive patterns

Strategy: validation

Validate before calling

if runtime.GOOS == "windows" && badgePid > 0 {
    // omit --pid; target the block/tab explicitly instead
}

Try / catch

if err != nil && strings.Contains(err.Error(), "not supported on Windows") {
    // rerun without --pid
}

Prevention

When it happens

Trigger: Running `wsh badge --pid <n> ...` on a Windows machine. Any positive --pid value triggers the check regardless of other flags.

Common situations: Cross-platform scripts that pass --pid unconditionally; documentation or shell examples copied from macOS/Linux usage and run on Windows; CI jobs running the same badge command on all platforms.

Understand the failure class

Background: "unsupported platform" / "not supported on this platform" errors: what they mean and how to fix them — this error's family across 47 libraries.

Related errors


AI-assisted analysis of wavetermdev/waveterm@a4447c1563 (2026-09-01). Data as JSON: /api/errors/a64d23001ff0ad48. Report an issue: GitHub.