Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
R
RIOT
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
cm-projects
RIOT
Commits
ab654573
Commit
ab654573
authored
11 years ago
by
Martine Lenders
Browse files
Options
Downloads
Patches
Plain Diff
Implementation of close()
parent
abe65b09
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
sys/posix/include/unistd.h
+49
-0
49 additions, 0 deletions
sys/posix/include/unistd.h
sys/posix/unistd.c
+30
-0
30 additions, 0 deletions
sys/posix/unistd.c
with
79 additions
and
0 deletions
sys/posix/include/unistd.h
0 → 100644
+
49
−
0
View file @
ab654573
/*
* Copyright (C) 2013 Freie Universität Berlin
*
* This file subject to the terms and conditions of the GNU Lesser General
* Public License. See the file LICENSE in the top level directory for more
* details.
*/
/**
* @addtogroup posix
* @{
*/
/**
* @file unistd.h
* @brief standard symbolic constants and types
* @see <a href="http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/unistd.h.html">
* The Open Group Base Specifications Issue 7, <unistd.h>
* </a>
*
* @author Freie Universität Berlin
* @author Martin Lenders <mlenders@inf.fu-berlin.de>
*/
#ifndef _UNISTD_H
#define _UNISTD_H
/**
* @brief Close a file descriptor.
* @details shall deallocate the file descriptor indicated by *fildes*. To
* deallocate means to make the file descriptor available for return
* by subsequent calls to open() or other functions that allocate file
* descriptors. All outstanding record locks owned by the process on
* the file associated with the file descriptor shall be removed (that
* is, unlocked).
*
* @see <a href="http://pubs.opengroup.org/onlinepubs/9699919799/functions/close.html">
* The Open Group Base Specification Issue 7, close
* </a>
*
* @param[in] fildes The file descriptor to the file which is to close.
* @return Upon successful completion, 0 shall be returned; otherwise, -1
* shall be returned and errno set to indicate the error.
*/
int
close
(
int
fildes
);
/**
* @}
*/
#endif
/* _UNISTD_H */
This diff is collapsed.
Click to expand it.
sys/posix/unistd.c
0 → 100644
+
30
−
0
View file @
ab654573
/*
* Copyright (C) 2013 Freie Universität Berlin
*
* This file subject to the terms and conditions of the GNU Lesser General
* Public License. See the file LICENSE in the top level directory for more
* details.
*/
#include
<errno.h>
#include
"fd.h"
#include
"unistd.h"
int
close
(
int
fildes
)
{
fd_t
*
fd_obj
=
fd_get
(
fildes
);
if
(
!
fd_obj
)
{
errno
=
EBADF
;
return
-
1
;
}
if
(
fd_obj
->
close
(
fd_obj
->
fd
)
<
0
)
{
errno
=
EIO
;
// EINTR may not occur since RIOT has no signals yet.
return
-
1
;
}
fd_destroy
(
fd_obj
->
fd
);
return
0
;
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment