ENOSTR
Linux / POSIXERRORNotableDeviceHIGH confidence
Device Not a Stream
Production Risk
Programming error — wrong API used for the file type.
What this means
ENOSTR (errno 60) is returned when a STREAMS-specific operation is attempted on a file descriptor that is not a STREAMS device.
Why it happens
- 1Calling a STREAMS ioctl (I_PUSH, I_POP, etc.) on a regular file or non-STREAMS fd
- 2Attempting getmsg()/putmsg() on a non-STREAMS descriptor
How to reproduce
getmsg() on a regular file descriptor.
trigger — this will error
trigger — this will error
int fd = open("/tmp/regular_file", O_RDWR);
struct strbuf ctrl = {0}, data = {0};
int flags = 0;
getmsg(fd, &ctrl, &data, &flags);
// Returns -1, errno = ENOSTRexpected output
getmsg: Device not a stream (ENOSTR)
Fix
Ensure the fd is a STREAMS device
WHEN Before calling getmsg/putmsg or STREAMS ioctls
Ensure the fd is a STREAMS device
// Check if fd is a STREAMS device
if (isastream(fd)) {
getmsg(fd, &ctrl, &data, &flags);
} else {
// Use regular read/write instead
read(fd, buf, sizeof(buf));
}Why this works
isastream() returns non-zero if the fd is a STREAMS device.
Sources
Official documentation ↗
Linux Programmer Manual errno(3)
Content generated with AI assistance and reviewed for accuracy. Found an error? hello@errcodes.dev