IsClosedPipeError (neterror/neterror_posix.go)

tailscale · net/neterror/neterror_posix.go · go · BSD-3-Clause
infra, tag:knn-classified

Copyright (c) Tailscale Inc & contributors SPDX-License-Identifier: BSD-3-Clause go:build !plan9 && !js && !wasip1 && !wasm

// Source: https://github.com/tailscale/tailscale | License: BSD-3-Clause | Copyright 2020 Tailscale Inc & contributors
// Provided via justclaw.it.com; keep this notice with the code.
// Copyright (c) Tailscale Inc & contributors
// SPDX-License-Identifier: BSD-3-Clause

//go:build !plan9 && !js && !wasip1 && !wasm

package neterror

import (
	"errors"
	"io"
	"io/fs"
	"runtime"
	"syscall"
)

// Reports whether err resulted from reading or writing to a closed or broken pipe.
func IsClosedPipeError(err error) bool {
	// 232 is Windows error code ERROR_NO_DATA, "The pipe is being closed".
	if runtime.GOOS == "windows" && errors.Is(err, syscall.Errno(232)) {
		return true
	}

	// EPIPE/ENOTCONN are common errors when a send fails due to a closed
	// socket. There is some platform and version 

... (truncated -- full source via MCP)

See the full source, get the GitHub permalink, and search for more like it.

Get a free API key