# panic: write to closed pipe

- **ID:** `go/io-write-to-closed-pipe`
- **Domain:** go
- **Category:** io_error
- **Verification:** ai_generated
- **Fix Rate:** 80%

## Root Cause

Writing to a pipe after the read end has been closed, often due to premature closure of the reader.

## Version Compatibility

| Version | Status | Introduced | Deprecated |
|---------|--------|------------|------------|
| 1.20 | active | — | — |
| 1.21 | active | — | — |

## Workarounds

1. **Use io.Pipe with proper error handling and synchronization** (90% success)
   ```
   pr, pw := io.Pipe()
// writer goroutine
go func() {
    defer pw.Close()
    _, err := pw.Write(data)
    if err != nil { log.Println(err) }
}()
// reader
data, err := io.ReadAll(pr)
   ```

## Dead Ends

- **Ignoring SIGPIPE signal** — Signal handling may not prevent panic; use proper synchronization. (60% fail)
