OPEN(2) Linux Programmer's Manual OPEN(2)
NAME
open, creat - open and possibly create a file or device
SYNOPSIS
#include<sys/types.h>#include<sys/stat.h>#include<fcntl.h>intopen(constchar*pathname,int flags);intopen(constchar*pathname,int flags, mode_t mode);intcreat(constchar*pathname, mode_t mode);
UNLINK(2) Linux Programmer's Manual UNLINK(2)
NAME
unlink - delete a name and possibly the file it refers to
SYNOPSIS
#include<unistd.h>intunlink(constchar*pathname);
DESCRIPTION
unlink() deletes a name from the file system. If that name was the last link to a file
and no processes have the file open the file is deleted and the space it was using is
made available for reuse.
If the name was the last link to a file but any processes still have the file open the
file will remain in existence until the last file descriptor referring to it is closed.
If the name referred to a symbolic link the link is removed.
If the name referred to a socket, fifo or device the name for it is removed but pro‐
cesses which have the object open may continue to use it.
3. chmod
CHMOD(2) Linux Programmer's Manual CHMOD(2)
NAME
chmod, fchmod - change permissions of a file
SYNOPSIS
#include<sys/stat.h>intchmod(constchar*path, mode_t mode);intfchmod(int fd, mode_t mode);
// example
pid_t pid =fork();if( pid <0){// error }elseif( pid ==0){// child process }else{// parent process// wait()}
6. signal kill alarm
SIGNAL(2) Linux Programmer's Manual SIGNAL(2)
NAME
signal - ANSI C signal handling
SYNOPSIS
#include<signal.h>typedefvoid(*sighandler_t)(int);
sighandler_t signal(int signum, sighandler_t handler);
KILL(2) Linux Programmer's Manual KILL(2)
NAME
kill - send signal to a process
SYNOPSIS
#include<sys/types.h>#include<signal.h>intkill(pid_t pid,int sig);
NAME
alarm - set an alarm clock for delivery of a signal
SYNOPSIS
#include<unistd.h>unsignedintalarm(unsignedint seconds);
7. POSIX Thread
PTHREAD_CREATE(3) Linux Programmer's Manual PTHREAD_CREATE(3)
NAME
pthread_create - create a new thread
SYNOPSIS
#include<pthread.h>intpthread_create(pthread_t *thread,const pthread_attr_t *attr,void*(*start_routine)(void*),void*arg);
Compile and link with -pthread.
PTHREAD_EXIT(3) Linux Programmer's Manual PTHREAD_EXIT(3)
NAME
pthread_exit - terminate calling thread
SYNOPSIS
#include<pthread.h>voidpthread_exit(void*retval);
Compile and link with -pthread.
PTHREAD_JOIN(3) Linux Programmer's Manual PTHREAD_JOIN(3)
NAME
pthread_join - join with a terminated thread
SYNOPSIS
#include<pthread.h>intpthread_join(pthread_t thread,void**retval);
Compile and link with -pthread.
8. Multi-thread Synchronization
SEM_INIT(3) Linux Programmer's Manual SEM_INIT(3)
NAME
sem_init - initialize an unnamed semaphore
SYNOPSIS
#include<semaphore.h>intsem_init(sem_t *sem,int pshared,unsignedint value);
Link with -pthread.
PTHREAD_MUTEX_DESTROY(3P) POSIX Programmer's Manual PTHREAD_MUTEX_DESTROY(3P)
PROLOG
This manual page is part of the POSIX Programmer's Manual. The Linux implementation of
this interface may differ (consult the corresponding Linux manual page for details of
Linux behavior), or the interface may not be implemented on Linux.
NAME
pthread_mutex_destroy, pthread_mutex_init - destroy and initialize a mutex
SYNOPSIS
#include<pthread.h>intpthread_mutex_destroy(pthread_mutex_t *mutex);intpthread_mutex_init(pthread_mutex_t *restrict mutex,const pthread_mutexattr_t *restrict attr);
pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER;
8. socket
SOCKET(2) Linux Programmer's Manual SOCKET(2)
NAME
socket - create an endpoint for communication
SYNOPSIS
#include<sys/types.h>/* See NOTES */#include<sys/socket.h>intsocket(int domain,int type,int protocol);
SELECT(2) Linux Programmer's Manual SELECT(2)
NAME
select, pselect, FD_CLR, FD_ISSET, FD_SET, FD_ZERO - synchronous I/O multiplexing
SYNOPSIS
/* According to POSIX.1-2001 */#include<sys/select.h>/* According to earlier standards */#include<sys/time.h>#include<sys/types.h>#include<unistd.h>intselect(int nfds, fd_set *readfds, fd_set *writefds,
fd_set *exceptfds,struct timeval *timeout);