Re: __attribute__((warn_unused_result)) for NetBSD?

Aleksey Cheusov <[email protected]>
Newsgroups gmane.os.netbsd.devel.general
Message-ID <[email protected]>
> On Sun, Sep 14, 2008 at 12:49:02PM +0300, Aleksey Cheusov wrote:
 >>
 >> Why? IMO Not checking for return value of all these functions as well
 >> as close fclose etc. is VERY dangerous.

> Please, explain to me what exactly you intend to do to handle an error
> return from close().

EINTR is very special.

int xclose (int fd)
{
	int ret;
	do {
		ret = close (fd);
	}while (ret == -1 && errno == EINTR);

	return ret;
}

void xclose_err (int fd)
{
	if (close (fd) == -1){
		perror ("close failed");
		exit (1);
	}
}

-- 
Best regards, Aleksey Cheusov.
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.