Learn C, C++ Concepts
Why no error handling from writev
Hi,Yes it is better to have a error check always, we missed that. You can use the following point to add the return check,"writev() return the number of bytes written. On error, -1 is returned, and errno is set appropriately."// make sure to add if (writev(1, iov, 3) == -1){ printf ("ERROR : writev failed - %s\n",strerror(errno));}else{ printf ("written - %d bytes\n", writev(1, iov, 3));}
Why no error handling from writev
ReplyDeleteHi,
DeleteYes it is better to have a error check always, we missed that. You can use the following point to add the return check,
"writev() return the number of bytes written. On error, -1 is returned, and errno is set appropriately."
// make sure to add
if (writev(1, iov, 3) == -1)
{
printf ("ERROR : writev failed - %s\n",strerror(errno));
}
else
{
printf ("written - %d bytes\n", writev(1, iov, 3));
}