On Sun, Oct 06, 2024 at 02:48:56PM -0300, Gustavo Rios wrote: > Hi folks! > > I am programming in obsd using the c coding language. I have a doubt > related to parameters and return value of write. My doubt is related to the > fact that write has a parameter of the number of bytes to write in > non-negative value. But it returns a signed value. Lets suppose i specify > as the parameter a number of bytes to write with the size of 2 ^ 31 - 100; > the internal represetation of signed and unsigned is the same, for > instance, -100 and 2^31 - 100 is the same value. > > In this scenario, how to handle a negative value of the return that is not > a error as signess result but is negative. > > How do you handle this? > > Thanks. > > PS: sorry for my poor english.
look at the man page: write will fail if the argument give is too large: [EINVAL] nbytes was larger than SSIZE_MAX. So it *is* an error to pass a too large size. -Otto