seaweedfs/seaweedfs · error

parent PID %d is invalid

Error message

parent PID %d is invalid

What it means

The `child=<pid>` option marks this weed process as the child half of the FUSE daemonization pair: the master re-execs the weed binary with `-o child=<master PID>` appended (fuse_std.go:311). The value parses as a 64-bit decimal int, then this panic fires when it is <= 0 or exceeds math.MaxInt. The normal producer is strconv.Itoa(os.Getpid()), which can never emit such a value, so hitting this means the child= option was hand-crafted, copied, or corrupted.

Source

Thrown at weed/command/fuse_std.go:115

	}

	// get residual option data
	if option.Len() > 0 {
		// add value to pending option
		options = append(options, parameter{option.String(), "true"})
		option.Reset()
	}

	// scan each parameter
	for i := 0; i < len(options); i++ {
		parameter := options[i]

		switch parameter.name {
		case "child":
			masterProcess = false
			if parsed, err := strconv.ParseInt(parameter.value, 10, 64); err == nil {
				if parsed > math.MaxInt || parsed <= 0 {
					panic(fmt.Errorf("parent PID %d is invalid", parsed))
				}
				mountOptions.fuseCommandPid = int(parsed)
			} else {
				panic(fmt.Errorf("parent PID %s is invalid: %w", parameter.value, err))
			}
		case "arg0":
			mountOptions.dir = &parameter.value
		case "filer":
			mountOptions.filer = &parameter.value
		case "filer.path":
			mountOptions.filerMountRootPath = &parameter.value
		case "dirAutoCreate":
			if parsed, err := strconv.ParseBool(parameter.value); err == nil {
				mountOptions.dirAutoCreate = &parsed
			} else {
				panic(fmt.Errorf("dirAutoCreate: %s", err))
			}
		case "collection":

View on GitHub (pinned to 1c926e8fac)

Solutions

  1. Remove `-o child=...` entirely - the master process appends it automatically when spawning the child
  2. If you must simulate a child, pass a live positive decimal PID such as `-o child=1234`
  3. Prefer `weed mount -dir=... -filer=...` which mounts directly and skips the master/child re-exec path
  4. On 32-bit builds, confirm the PID fits in int32 (kernel pid_max caps at 4194304, so this is normally automatic)

Example fix

// before
weed fuse /mnt/sw -o "filer=localhost:8888,child=0"

// after
weed fuse /mnt/sw -o "filer=localhost:8888"
// child=<master pid> is appended automatically by the master process
Defensive patterns

Strategy: validation

Validate before calling

# bash: reject bogus child= values before invoking the helper
if [[ "$opts" =~ child=([^ ,]*) ]]; then
  pid="${BASH_REMATCH[1]}"
  [[ "$pid" =~ ^[1-9][0-9]*$ ]] || { echo "bad child pid: $pid" >&2; exit 1; }
fi

Type guard

func isValidChildPid(v string) bool {
	parsed, err := strconv.ParseInt(v, 10, 64)
	return err == nil && parsed > 0 && parsed <= int64(math.MaxInt)
}

Prevention

When it happens

Trigger: Invoking the fuse helper with an explicit `-o child=0` or `-o child=-5`; a 32-bit weed build receiving child=2500000000 (> MaxInt32); scripts that rebuild the master argv and mangle the PID field.

Common situations: Manually re-running the child command copied from `ps` output; systemd/wrapper units that rewrite argv; shell quoting bugs that truncate the value to 0.

Related errors


AI-assisted analysis of seaweedfs/seaweedfs@1c926e8fac (2026-08-15). Data as JSON: /api/errors/dd7912ea3cf578bf. Report an issue: GitHub.