tech-misc archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: __attribute__((warn_unused_result)) for NetBSD?



> 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.


Home | Main Index | Thread Index | Old Index