projects
/
ccan
/ blob
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
history
|
raw
|
HEAD
Move modules to ccan/ tools to tools/
[ccan]
/
ccan
/
noerr
/
noerr.c
1
#include "noerr.h"
2
#include <unistd.h>
3
#include <errno.h>
4
5
int close_noerr(int fd)
6
{
7
int saved_errno = errno, ret;
8
9
if (close(fd) != 0)
10
ret = errno;
11
else
12
ret = 0;
13
14
errno = saved_errno;
15
return ret;
16
}
17
18
int unlink_noerr(const char *pathname)
19
{
20
int saved_errno = errno, ret;
21
22
if (unlink(pathname) != 0)
23
ret = errno;
24
else
25
ret = 0;
26
27
errno = saved_errno;
28
return ret;
29
}