Skip to content

gitisabel/unix-system-programming

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

10 Commits
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

🐧 unix-system-programming

C POSIX License: MIT

Deep-dive implementations of UNIX systems concepts: processes, signals, IPC, sockets


πŸ“– Overview

A collection of systems programming exercises covering the full UNIX API surface. Each module is self-contained with its own Makefile, annotated source, and test harness. Built to demonstrate mastery of low-level UNIX programming.


πŸ—οΈ Modules

unix-system-programming/
β”œβ”€β”€ 01-processes/
β”‚   β”œβ”€β”€ fork_exec.c       # fork + execve + waitpid patterns
β”‚   └── process_tree.c    # Build a process tree, print with indentation
β”œβ”€β”€ 02-signals/
β”‚   β”œβ”€β”€ signal_handler.c  # sigaction, SA_RESTART, signal masks
β”‚   └── job_control.c     # SIGCHLD, SIGTSTP, fg/bg job tracking
β”œβ”€β”€ 03-ipc/
β”‚   β”œβ”€β”€ pipe_redir.c      # Pipes and dup2 for shell-style redirection
β”‚   β”œβ”€β”€ shared_mem.c      # POSIX shm_open + mmap producer-consumer
β”‚   └── message_queue.c   # POSIX mq_open for async messaging
β”œβ”€β”€ 04-sockets/
β”‚   β”œβ”€β”€ tcp_server.c      # Concurrent TCP server with poll()
β”‚   └── unix_socket.c     # AF_UNIX datagram socket IPC
β”œβ”€β”€ 05-threads/
β”‚   β”œβ”€β”€ thread_pool.c     # POSIX threads + condition variables
β”‚   └── rwlock.c          # Read-write lock from scratch
└── README.md

πŸš€ Quick Start

git clone https://github.com/gitisabel/unix-system-programming
cd unix-system-programming/04-sockets
make
./tcp_server &
./tcp_client 127.0.0.1 8080

πŸ”‘ Highlights

// Non-blocking poll()-based TCP server (04-sockets/tcp_server.c)
int epfd = epoll_create1(0);
epoll_ctl(epfd, EPOLL_CTL_ADD, listenfd, &ev);
while (1) {
    int n = epoll_wait(epfd, events, MAX_EVENTS, -1);
    for (int i = 0; i < n; i++) handle_event(&events[i]);
}

πŸ§ͺ Tests

Each module has a make test target that runs correctness checks and checks for fd/memory leaks with valgrind.


πŸ“„ License

MIT Β© Isabel

About

🐧 Unix systems programming in C β€” processes, signals, pipes, IPC and file descriptors

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors