Linux ESPIPE (errno 29) — Illegal Seek on Pipe/Socket
Informationalerrno
Overview
Linux ESPIPE error occurs when a program tries to seek (reposition) within a pipe, socket, or FIFO which does not support random access.
Key Details
- ESPIPE (errno 29) means lseek() was called on a file descriptor that does not support seeking
- Pipes, sockets, FIFOs, and some special files are sequential-only streams
- Common when a program designed for regular files receives a pipe via shell redirection
- Applications that check file size (fstat then lseek to end) fail on pipe input
- Some compression tools need to seek backward and cannot work with pipes
Common Causes
- Program using lseek() on stdin when input is piped (cat file | program)
- Application trying to read file size of a pipe or socket
- Compression/archive tool needing random access but receiving a stream
- Database trying to seek within a network socket connection
- Shell script using seek operations on a FIFO special file
Steps
- 1Use a temporary file instead of a pipe: command > /tmp/data && program /tmp/data
- 2Use process substitution: program <(command) — creates a regular file descriptor on some systems
- 3For input from pipe: buffer entire input to a temp file first, then process
- 4Check if the program supports reading from stdin without seeking (--stdin or - flag)
- 5Use named pipe with appropriate buffering: mkfifo /tmp/mypipe
Tags
linuxespipeerrno-29seekpipe
More in Errno
linux-errno-1-epermLinux errno 1 (EPERM) — Operation Not Permitted
Warninglinux-errno-2-enoentLinux errno 2 (ENOENT) — No Such File or Directory
Warninglinux-errno-5-eioLinux errno 5 (EIO) — Input/Output Error
Errorlinux-errno-11-eagainLinux errno 11 (EAGAIN) — Resource Temporarily Unavailable
Informationallinux-errno-12-enomemLinux errno 12 (ENOMEM) — Out of Memory
Criticallinux-errno-13-eaccesLinux errno 13 (EACCES) — Permission Denied
WarningFrequently Asked Questions
Pipes are one-directional streams with no random access. Data flows from writer to reader sequentially — there is nothing to seek to.