Chapter 131. POSIX Standard Support

eCos contains support for the POSIX Specification (ISO/IEC 9945-1)[POSIX].

POSIX support is divided between the POSIX and the FILEIO packages. The POSIX package provides support for threads, signals, synchronization, timers and message queues. The FILEIO package provides support for file and device I/O. The two packages may be used together or separately, depending on configuration.

This document takes a functional approach to the POSIX library. Support for a function implies that the data types and definitions necessary to support that function, and the objects it manipulates, are also defined. Any exceptions to this are noted, and unless otherwise noted, implemented functions behave as specified in the POSIX standard.

This document only covers the differences between the eCos implementation and the standard; it does not provide complete documentation. For full information, see the POSIX standard [POSIX]. Online, the Open Group Single Unix Specification [SUS2] provides complete documentation of a superset of POSIX. If you have access to a Unix system with POSIX compatibility, then the manual pages for this will be of use. There are also a number of books available. [Lewine] covers the process, signal, file and I/O functions, while [Lewis1], [Lewis2], [Nichols] and [Norton] cover Pthreads and related topics (see Bibliography, xref). However, many of these books are oriented toward using POSIX in non-embedded systems, so care should be taken in applying them to programming under eCos.

The remainder of this chapter broadly follows the structure of the POSIX Specification. References to the appropriate section of the Standard are included.

Omitted functions marked with “// TBA” are potential candidates for later implementation.

Process Primitives [POSIX Section 3]

Functions Implemented

int kill(pid_t pid, int sig); 
int pthread_kill(pthread_t thread, int sig); 
int sigaction(int sig, const struct sigaction *act,
              struct sigaction *oact); 
int sigqueue(pid_t pid, int sig, const union sigval value); 
int sigprocmask(int how, const sigset_t *set,
                sigset_t *oset); 
int pthread_sigmask(int how, const sigset_t *set,
                    sigset_t *oset); 
int sigpending(sigset_t *set);
int sigsuspend(const sigset_t *set); 
int sigwait(const sigset_t *set, int *sig); 
int sigwaitinfo(const sigset_t *set, siginfo_t *info); 
int sigtimedwait(const sigset_t *set, siginfo_t *info,
                 const struct timespec *timeout); 
int sigemptyset(sigset_t *set); 
int sigfillset(sigset_t *set); 
int sigaddset(sigset_t *set, int signo); 
int sigdelset(sigset_t *set, int signo); 
int sigismember(const sigset_t *set, int signo);
unsigned int alarm( unsigned int seconds );
int pause( void ); 
unsigned int sleep( unsigned int seconds );

Functions Omitted

pid_t fork(void); 
int execl( const char *path, const char *arg, ... ); 
int execv( const char *path, char *const argv[] ); 
int execle( const char *path, const char *arg, ... ); 
int execve( const char *path, char *const argv[],
            char *const envp[] ); 
int execlp( const char *path, const char *arg, ... ); 
int execvp( const char *path, char *const argv[] ); 
int pthread_atfork( void(*prepare)(void),
                    void (*parent)(void),
                    void (*child)() );
pid_t wait( int *stat_loc );		    
pid_t waitpid( pid_t pid, int *stat_loc,
               int options ); 
void _exit( int status );


  • Signal handling may be enabled or disabled with the CYGPKG_POSIX_SIGNALS option. Since signals are used by other POSIX components, such as timers, disabling signals will disable those components too.

  • kill() and sigqueue() may only take a pid argument of zero, which maps to the current process.

  • The SIGEV_THREAD notification type is not currently implemented.

  • Job Control and Memory Protection signals are not supported.

  • An extra implementation defined si_code value, SI_EXCEPT, is defined to distinguish hardware generated exceptions from others.

  • Extra signals are defined: _SIGTRAP_,_SIGIOT_, _SIGEMT_, and _SIGSYS_. These are largely to maintain compatibility with the signal numbers used by GDB.

  • Signal delivery may currently occur at unexpected places in some API functions. Using longjmp() to transfer control out of a signal handler may result in the interrupted function not being able to complete properly. This may result in later function calls failing or deadlocking.

Documentation license for this page: Open Publication License