c - What's the semantic difference between ERANGE and EOVERFLOW? -


the errno value erange documented posix as

result large.

and eoverflow documented as

value large stored in data type.

what's semantic difference between these two? considering erange used iso 9899 (e.g. in strtol) semantic described eoverflow. these 2 errno values distinct historical reasons?

please arguments appropriate sources if possible.

singleunix quite verbose eoverflow:

value large stored in data type user id or group id of ipc or file system object large stored appropriate member of caller-provided structure. error occur on implementations support larger range of user id or group id values declared structure member can support. occurs because ipc or file system object resides on remote machine larger value of type uid_t, off_t or gid_t local system.

eoverflow seems intended signal subsystem incompatibility, i.e. system returned larger value subsystem can handle.

eoverflow explained in more detail in rationale:

most of uses of error code related large file support. typically, these cases occur on systems support multiple programming environments different sizes off_t, may occur in connection remote file systems.

in addition, when different programming environments have different widths types such int , uid_t, several functions may encounter condition value in particular environment wide represented. in case, error should raised. example, suppose running process has 64-bit int, , file descriptor 9223372036854775807 open , not have close-on- exec flag set. if process uses execl() exec file compiled in programming environment 32-bit int, call execl() can fail errno set [eoverflow]. similar failure can occur execl() if of user ids or of group ids assigned new process image out of range executed file's programming environment.

note, however, condition cannot occur functions explicitly described being successful, such getpid().

thanks @rici pointer

erange more this won't ever fit. strtol() 1 example. another, less clear one: trying increment sysv semaphore past configured limit returns erange.

with eoverflow data there, not fit local data structure(s).

for example, lseek() can return eoverflow. happens, e.g. when off_t 32bit file system can support larger files , try seek past range os can handle. why isn't erange? because system can handle operation in principle, cannot return in data type available.

trying map more 2g using mmap() on 32bit system on linux returns eoverflow (other systems return einval).

unfortunately, not totally consistent. example, bluetooth stack returns eoverflow when finds many host controllers in system.


Comments