记录学习 Linux 系统编程过程中一些系统接口的用法。 定位是 demo,所以代码写的比较随意,也会有重复代码。 重点是为了演示某些系统接口的基本用法。
基本上每个示例都是一个文件,可以独立编译和运行,但要使用 gcc 5 及以上版本。
Document TODO
- 待完成
IO
- big file
- file lock(flock / fctrl)
- inotify
- select / poll / epoll
- pipe
- popen
- pwrite
- stat
- syslog
- FILE <==> fd
- tmpfile
- fifo
directory
- dirname / basename / realpath / getcwd
- opendir / readdir / closedir
- nftw(file tree walk)
socket
- internet datagram / stream
- UNIX domain datagram / stream
- simple http client
signal
- signal
- sigaction
time
- POSIX (real time and ticks)
- clock_gettime / clock_settime
- clock / getrusage
- UNIX (real time and ticks)
- gettimeofday / time
- ctime_r / gmtime_r / localtime_r
- strftime / strptime
- times
- sleep
- sleep / usleep / nanosleep
- select / poll / epoll
- clock_nanosleep
timer
- POSIX
- timer_create / timer_delete
- timer_gettime / timer_settime / timer_getoverrun
- Linux
- timerfd_create / timerfd_gettime / timerfd_settime
memory
- basic
- alloc / malloc / free
- sbrk
- memalign / posix_memalign
- map file (shared or private)
process
- fork / getpid
- system-v-ipc
- shared-memory
- semaphore
- posix-ipc
- shared-memory
- semaphore
- message-queue
thread
- pthread_create / pthread_once / pthread_detach / pthread_join
- pthread_cancel
- Thread-local storage / Thread-specific Data
- synchronization
- mutex
- condition
- RW-Lock
- spinlock
other
- cmake
- libc IO