Tenok
A Linux-like Real-Time Operating System for Robotics and Internet of Things
Macros | Functions
unistd.h File Reference
#include <stddef.h>
#include <stdint.h>
#include <sys/types.h>
#include "kconfig.h"
Include dependency graph for unistd.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define MQ_PRIO_MAX   _MQ_PRIO_MAX
 
#define STDIN_FILENO   0 /* Standard input file descriptor */
 
#define STDOUT_FILENO   1 /* Standard output file descriptor */
 
#define STDERR_FILENO   2 /* Standard error file descriptor */
 

Functions

unsigned int sleep (unsigned int seconds)
 To cause the calling thread to sleep either until the number of real-time seconds specified in seconds have elapsed or until a signal arrives which is not ignored. More...
 
int usleep (useconds_t usec)
 Suspend execution of the calling thread for a given time in microseconds. More...
 
int close (int fd)
 Close a file descriptor, so that it no longer refers to any file and may be reused. More...
 
int dup (int oldfd)
 Create a copy of the file descriptor oldfd, using the lowest-numbered unused file descriptor for the new descriptor. More...
 
int dup2 (int oldfd, int newfd)
 Perform the same task as dup(), but use the file descriptor number specified by newfd. More...
 
ssize_t read (int fd, void *buf, size_t count)
 Attempt to read up to count bytes from file descriptor fd into the buffer starting at buf. More...
 
ssize_t write (int fd, const void *buf, size_t count)
 Write up to count bytes from the buffer starting at buf to the file referred to by the file descriptor fd. More...
 
off_t lseek (int fd, long offset, int whence)
 Reposition the file offset of the open file description associated with the file descriptor fd. More...
 
int getpid (void)
 Return the ID of the calling task. More...
 
char * getcwd (char *buf, size_t size)
 Get current working directory. More...
 
int chdir (const char *path)
 Change working directory. More...
 

Function Documentation

◆ chdir()

int chdir ( const char *  path)

Change working directory.

Parameters
pathPathname of the new working directory.
Return values
int0 on success and nonzero error number on error.

◆ close()

int close ( int  fd)

Close a file descriptor, so that it no longer refers to any file and may be reused.

Parameters
fdThe file descriptor to provide.
Return values
int0 on success and nonzero error number on error.

◆ dup()

int dup ( int  oldfd)

Create a copy of the file descriptor oldfd, using the lowest-numbered unused file descriptor for the new descriptor.

Parameters
oldfdThe file descriptor to duplicate.
Return values
intNew file descriptor on success and nonzero error number on error.

◆ dup2()

int dup2 ( int  oldfd,
int  newfd 
)

Perform the same task as dup(), but use the file descriptor number specified by newfd.

Parameters
oldfdThe file descriptor to duplicate.
newfdThe number to specify the new file descriptor.
Return values
intNew file descriptor on success and nonzero error number on error.

◆ getcwd()

char* getcwd ( char *  buf,
size_t  size 
)

Get current working directory.

Parameters
bufBuffer space for storing path of the current working space.
sizeSize of the buffer space.
Return values
char*: The function returns a pointer to a string containing the pathname of current working directory if success; otherwise it returns NULL.

◆ getpid()

int getpid ( void  )

Return the ID of the calling task.

Parameters
None
Return values
intTask ID.

◆ lseek()

off_t lseek ( int  fd,
long  offset,
int  whence 
)

Reposition the file offset of the open file description associated with the file descriptor fd.

Parameters
fdThe file descriptor to provide.
offsetThe new offset to the position specified by whence.
whenceThe start position of the new offset.
Return values
int0 on success and nonzero error number on error.

◆ read()

ssize_t read ( int  fd,
void *  buf,
size_t  count 
)

Attempt to read up to count bytes from file descriptor fd into the buffer starting at buf.

Parameters
fdThe file descriptor to provide.
bufThe memory space for storing read data.
countThe number of bytes to read.
Return values
int0 on success and nonzero error number on error.

◆ sleep()

unsigned int sleep ( unsigned int  seconds)

To cause the calling thread to sleep either until the number of real-time seconds specified in seconds have elapsed or until a signal arrives which is not ignored.

Parameters
secondsThe sleep seconds to provide.
Return values
int0 on success and nonzero error number on error.

◆ usleep()

int usleep ( useconds_t  usec)

Suspend execution of the calling thread for a given time in microseconds.

Parameters
usecThe sleep microseconds to provide.
Return values
int0 on success and nonzero error number on error.

◆ write()

ssize_t write ( int  fd,
const void *  buf,
size_t  count 
)

Write up to count bytes from the buffer starting at buf to the file referred to by the file descriptor fd.

Parameters
fdThe file descriptor to provide.
bufThe data to write.
countThe number of bytes to write.
Return values
int0 on success and nonzero error number on error.