Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
C
criu
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
zhul
criu
Commits
401464d2
Commit
401464d2
authored
Sep 27, 2011
by
Cyrill Gorcunov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add close_safe helper
Signed-off-by:
Cyrill Gorcunov
<
gorcunov@gmail.com
>
parent
aff6918b
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
15 additions
and
0 deletions
+15
-0
util.h
include/util.h
+1
-0
util.c
util.c
+14
-0
No files found.
include/util.h
View file @
401464d2
...
...
@@ -148,6 +148,7 @@ void printk_vma(struct vma_area *vma_area);
int
reopen_fd_as
(
int
new_fd
,
int
old_fd
);
int
parse_maps
(
pid_t
pid
,
struct
list_head
*
vma_list
);
int
close_safe
(
int
*
fd
);
#define __xalloc(op, size, ...) \
({ \
...
...
util.c
View file @
401464d2
...
...
@@ -226,6 +226,20 @@ err_cont:
goto
err
;
}
int
close_safe
(
int
*
fd
)
{
int
ret
=
0
;
if
(
*
fd
>
-
1
)
{
ret
=
close
(
*
fd
);
if
(
!
ret
)
*
fd
=
-
1
;
else
pr_perror
(
"Unable to close fd: %d
\n
"
,
*
fd
);
}
return
ret
;
}
int
reopen_fd_as
(
int
new_fd
,
int
old_fd
)
{
if
(
old_fd
!=
new_fd
)
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment