The Linux Programming Interface
Linux Programmer's Manual
http://www.man7.org/index.html
List of source code files, by chapter, from The Linux Programming Interface
The following is a list of all source code files from the book, The Linux Programming Interface, broken down by chapter.
Chapter 3: System Programming Concepts
- lib/tlpi_hdr.h (Listing 3-1)
- lib/error_functions.h (Listing 3-2)
- lib/error_functions.c (Listing 3-3)
- lib/ename.c.inc (Listing 3-4)
- lib/get_num.h (Listing 3-5)
- lib/get_num.c (Listing 3-6)
- lib/alt_functions.c
- lib/alt_functions.h
- progconc/syscall_speed.c
Chapter 4: File I/O: The Universal I/O Model
- fileio/copy.c (Listing 4-1)
- fileio/seek_io.c (Listing 4-3)
Chapter 5: File I/O: Further Details
- fileio/bad_exclusive_open.c (Listing 5-1)
- fileio/t_readv.c (Listing 5-2)
- fileio/large_file.c (Listing 5-3)
- fileio/atomic_append.c (Solution to Exercise 5-3)
- fileio/multi_descriptors.c (Solution to Exercise 5-6)
- fileio/t_truncate.c
Chapter 6: Processes
- proc/mem_segments.c (Listing 6-1)
- proc/necho.c (Listing 6-2)
- proc/display_env.c (Listing 6-3)
- proc/modify_env.c (Listing 6-4)
- proc/longjmp.c (Listing 6-5)
- proc/setjmp_vars.c (Listing 6-6)
- proc/bad_longjmp.c (Solution to Exercise 6-2)
- proc/setenv.c (Solution to Exercise 6-3)
- proc/t_getenv.c
Chapter 8: Users and Groups
- users_groups/ugid_functions.c (Listing 8-1)
- users_groups/ugid_functions.h (Header file for Listing 8-1)
- users_groups/check_password.c (Listing 8-2)
- users_groups/t_getpwent.c
- users_groups/t_getpwnam_r.c
Chapter 10: Time
- time/calendar_time.c (Listing 10-1)
- time/curr_time.c (Listing 10-2)
- time/curr_time.h (Header file for Listing 10-2)
- time/strtime.c (Listing 10-3)
- time/show_time.c (Listing 10-4)
- time/process_time.c (Listing 10-5)
- time/t_stime.c
Chapter 11: System Limits and Options
- syslim/t_sysconf.c (Listing 11-1)
- syslim/t_fpathconf.c (Listing 11-2)
Chapter 12: System and Process Information
- sysinfo/procfs_pidmax.c (Listing 12-1)
- sysinfo/t_uname.c (Listing 12-2)
- sysinfo/procfs_user_exe.c (Solution to Exercise 12-1)
Chapter 13: File I/O Buffering
- filebuff/direct_read.c (Listing 13-1)
- filebuff/mix23_linebuff.c (Solution to Exercise 13-4)
- filebuff/mix23io.c
- filebuff/write_bytes.c
Chapter 14: File Systems
- filesys/t_mount.c (Listing 14-1)
- filesys/t_statfs.c
- filesys/t_statvfs.c
- filesys/t_umount.c
Chapter 15: File Attributes
- files/t_stat.c (Listing 15-1)
- files/t_chown.c (Listing 15-2)
- files/file_perms.h (Listing 15-3)
- files/file_perms.c (Listing 15-4)
- files/t_umask.c (Listing 15-5)
- files/chiflag.c (Solution to Exercise 15-7)
- files/t_utime.c
- files/t_utimes.c
Chapter 18: Directories and Links
- dirs_links/t_unlink.c (Listing 18-1)
- dirs_links/list_files.c (Listing 18-2)
- dirs_links/nftw_dir_tree.c (Listing 18-3)
- dirs_links/view_symlink.c (Listing 18-4)
- dirs_links/t_dirbasename.c (Listing 18-5)
- dirs_links/bad_symlink.c (Solution to Exercise 18-2)
- dirs_links/list_files_readdir_r.c (Solution to Exercise 18-4)
- dirs_links/file_type_stats.c (Solution to Exercise 18-7)
Chapter 19: Monitoring File Events
Chapter 20: Signals: Fundamental Concepts
- signals/ouch.c (Listing 20-1)
- signals/intquit.c (Listing 20-2)
- signals/t_kill.c (Listing 20-3)
- signals/signal_functions.c (Listing 20-4)
- signals/signal_functions.h (Header file for Listing 20-4)
- signals/sig_sender.c (Listing 20-6)
- signals/sig_receiver.c (Listing 20-7)
- signals/ignore_pending_sig.c (Solution to Exercise 20-2)
- signals/siginterrupt.c (Solution to Exercise 20-4)
Chapter 21: Signals: Signal Handlers
- signals/nonreentrant.c (Listing 21-1)
- signals/sigmask_longjmp.c (Listing 21-2)
- signals/t_sigaltstack.c (Listing 21-3)
Chapter 22: Signals: Advanced Features
- signals/signal.c (Listing 22-1)
- signals/t_sigqueue.c (Listing 22-2)
- signals/catch_rtsigs.c (Listing 22-3)
- signals/t_sigsuspend.c (Listing 22-5)
- signals/t_sigwaitinfo.c (Listing 22-6)
- signals/signalfd_sigval.c (Listing 22-7)
- signals/demo_SIGFPE.c
- signals/sig_speed_sigsuspend.c
Chapter 23: Timers and Sleeping
- timers/real_timer.c (Listing 23-1)
- timers/timed_read.c (Listing 23-2)
- timers/t_nanosleep.c (Listing 23-3)
- timers/ptmr_sigev_signal.c (Listing 23-5)
- timers/itimerspec_from_str.c (Listing 23-6)
- timers/itimerspec_from_str.h (Header file for Listing 23-6)
- timers/ptmr_sigev_thread.c (Listing 23-7)
- timers/demo_timerfd.c (Listing 23-8)
- timers/t_clock_nanosleep.c (Solution to Exercise 23-2)
- timers/ptmr_null_evp.c (Solution to Exercise 23-3)
- timers/cpu_burner.c
- timers/cpu_multi_burner.c
- timers/cpu_multithread_burner.c
Chapter 24: Process Creation
- procexec/t_fork.c (Listing 24-1)
- procexec/fork_file_sharing.c (Listing 24-2)
- procexec/footprint.c (Listing 24-3)
- procexec/t_vfork.c (Listing 24-4)
- procexec/fork_whos_on_first.c (Listing 24-5)
- procexec/fork_sig_sync.c (Listing 24-6)
- procexec/vfork_fd_test.c (Solution to Exercise 24-2)
Chapter 25: Process Termination
- procexec/exit_handlers.c (Listing 25-1)
- procexec/fork_stdio_buf.c (Listing 25-2)
Chapter 26: Monitoring Child Processes
- procexec/multi_wait.c (Listing 26-1)
- procexec/print_wait_status.c (Listing 26-2)
- procexec/print_wait_status.h (Header file for Listing 26-2)
- procexec/child_status.c (Listing 26-3)
- procexec/make_zombie.c (Listing 26-4)
- procexec/multi_SIGCHLD.c (Listing 26-5)
- procexec/orphan.c (Solution to Exercise 26-1)
- procexec/pdeath_signal.c
Chapter 27: Program Execution
- procexec/t_execve.c (Listing 27-1)
- procexec/envargs.c (Listing 27-2)
- procexec/t_execlp.c (Listing 27-3)
- procexec/t_execle.c (Listing 27-4)
- procexec/t_execl.c (Listing 27-5)
- procexec/closeonexec.c (Listing 27-6)
- procexec/t_system.c (Listing 27-7)
- procexec/simple_system.c (Listing 27-8)
- procexec/system.c (Listing 27-9)
- procexec/execlp.c (Solution to Exercise 27-2)
Chapter 28: Process Creation and Program Execution in More Detail
- procexec/acct_on.c (Listing 28-1)
- procexec/acct_view.c (Listing 28-2)
- procexec/t_clone.c (Listing 28-3)
- procexec/acct_v3_view.c
- procexec/demo_clone.c
Chapter 29: Threads: Introduction
- threads/simple_thread.c (Listing 29-1)
- threads/detached_attrib.c (Listing 29-2)
Chapter 30: Threads: Thread Synchronization
- threads/thread_incr.c (Listing 30-1)
- threads/thread_incr_mutex.c (Listing 30-2)
- threads/thread_multijoin.c (Listing 30-4)
- threads/prod_condvar.c
- threads/prod_no_condvar.c
- threads/pthread_barrier_demo.c
Chapter 31: Threads: Thread Safety and Per-Thread Storage
- threads/strerror.c (Listing 31-1)
- threads/strerror_test.c (Listing 31-2)
- threads/strerror_tsd.c (Listing 31-3)
- threads/strerror_tls.c (Listing 31-4)
- threads/one_time_init.c (Solution to Exercise 31-1)
Chapter 32: Threads: Thread Cancellation
- threads/thread_cancel.c (Listing 32-1)
- threads/thread_cleanup.c (Listing 32-2)
Chapter 33: Threads: Further Details
Chapter 34: Process Groups, Sessions, and Job Control
- pgsjc/t_setsid.c (Listing 34-2)
- pgsjc/catch_SIGHUP.c (Listing 34-3)
- pgsjc/disc_SIGHUP.c (Listing 34-4)
- pgsjc/job_mon.c (Listing 34-5)
- pgsjc/handling_SIGTSTP.c (Listing 34-6)
- pgsjc/orphaned_pgrp_SIGHUP.c (Listing 34-7)
Chapter 35: Process Priorities and Scheduling
- procpri/t_setpriority.c (Listing 35-1)
- procpri/sched_set.c (Listing 35-2)
- procpri/sched_view.c (Listing 35-3)
- procpri/demo_sched_fifo.c (Solution to Exercise 35-3)
- procpri/t_sched_getaffinity.c
- procpri/t_sched_setaffinity.c
Chapter 36: Process Resources
- procres/print_rlimit.c (Listing 36-2)
- procres/print_rlimit.h (Header file for Listing 36-2)
- procres/rlimit_nproc.c (Listing 36-3)
- procres/rusage_wait.c (Solution to Exercise 36-1)
- procres/rusage.c (Solution to Exercise 36-2)
- procres/print_rusage.c (Solution to Exercise 36-2)
- procres/print_rusage.h (Solution to Exercise 36-2)
Chapter 37: Daemons
- daemons/become_daemon.h (Listing 37-1)
- daemons/become_daemon.c (Listing 37-2)
- daemons/daemon_SIGHUP.c (Listing 37-3)
- daemons/t_syslog.c (Solution to Exercise 37-1)
- daemons/test_become_daemon.c
Chapter 39: Capabilities
Chapter 40: Login Accounting
- loginacct/dump_utmpx.c (Listing 40-2)
- loginacct/utmpx_login.c (Listing 40-3)
- loginacct/view_lastlog.c (Listing 40-4)
Chapter 44: Pipes and FIFOs
- pipes/simple_pipe.c (Listing 44-2)
- pipes/pipe_sync.c (Listing 44-3)
- pipes/pipe_ls_wc.c (Listing 44-4)
- pipes/popen_glob.c (Listing 44-5)
- pipes/fifo_seqnum.h (Listing 44-6)
- pipes/fifo_seqnum_server.c (Listing 44-7)
- pipes/fifo_seqnum_client.c (Listing 44-8)
- pipes/change_case.c (Solution to Exercise 44-1)
Chapter 45: Introduction to System V IPC
- svipc/svmsg_demo_server.c (Listing 45-1)
- svipc/t_ftok.c (Solution to Exercise 45-2)
Chapter 46: System V Message Queues
- svmsg/svmsg_create.c (Listing 46-1)
- svmsg/svmsg_send.c (Listing 46-2)
- svmsg/svmsg_receive.c (Listing 46-3)
- svmsg/svmsg_rm.c (Listing 46-4)
- svmsg/svmsg_chqbytes.c (Listing 46-5)
- svmsg/svmsg_ls.c (Listing 46-6)
- svmsg/svmsg_file.h (Listing 46-7)
- svmsg/svmsg_file_server.c (Listing 46-8)
- svmsg/svmsg_file_client.c (Listing 46-9)
- svmsg/svmsg_info.c
Chapter 47: System V Semaphores
- svsem/svsem_demo.c (Listing 47-1)
- svsem/semun.h (Listing 47-2)
- svsem/svsem_mon.c (Listing 47-3)
- svsem/svsem_setall.c (Listing 47-4)
- svsem/svsem_bad_init.c (Listing 47-5)
- svsem/svsem_good_init.c (Listing 47-6)
- svsem/svsem_op.c (Listing 47-8)
- svsem/binary_sems.h (Listing 47-9)
- svsem/binary_sems.c (Listing 47-10)
- svsem/event_flags.c (Solution to Exercise 47-5)
- svsem/event_flags.h (Solution to Exercise 47-5)
- svsem/svsem_create.c
- svsem/svsem_info.c
- svsem/svsem_rm.c
Chapter 48: System V Shared Memory
- svshm/svshm_xfr.h (Listing 48-1)
- svshm/svshm_xfr_writer.c (Listing 48-2)
- svshm/svshm_xfr_reader.c (Listing 48-3)
- svshm/svshm_mon.c (Solution to Exercise 48-4)
- svshm/svshm_attach.c
- svshm/svshm_create.c
- svshm/svshm_info.c
- svshm/svshm_lock.c
- svshm/svshm_rm.c
- svshm/svshm_unlock.c
Chapter 49: Memory Mappings
- mmap/mmcat.c (Listing 49-1)
- mmap/t_mmap.c (Listing 49-2)
- mmap/anon_mmap.c (Listing 49-3)
- mmap/mmcopy.c (Solution to Exercise 49-1)
- mmap/t_remap_file_pages.c
Chapter 50: Virtual Memory Operations
- vmem/t_mprotect.c (Listing 50-1)
- vmem/memlock.c (Listing 50-2)
- vmem/madvise_dontneed.c (Solution to Exercise 50-2)
Chapter 52: POSIX Message Queues
- pmsg/pmsg_unlink.c (Listing 52-1)
- pmsg/pmsg_create.c (Listing 52-2)
- pmsg/pmsg_getattr.c (Listing 52-3)
- pmsg/pmsg_send.c (Listing 52-4)
- pmsg/pmsg_receive.c (Listing 52-5)
- pmsg/mq_notify_sig.c (Listing 52-6)
- pmsg/mq_notify_thread.c (Listing 52-7)
- pmsg/mq_notify_sigwaitinfo.c (Solution to Exercise 52-6)
- pmsg/mq_notify_via_signal.c
- pmsg/mq_notify_via_thread.c
Chapter 53: POSIX Semaphores
- psem/psem_create.c (Listing 53-1)
- psem/psem_unlink.c (Listing 53-2)
- psem/psem_wait.c (Listing 53-3)
- psem/psem_post.c (Listing 53-4)
- psem/psem_getvalue.c (Listing 53-5)
- psem/thread_incr_psem.c (Listing 53-6)
- psem/psem_timedwait.c (Solution to Exercise 53-2)
- pmsg/mq_notify_siginfo.c
- psem/psem_trywait.c
Chapter 54: POSIX Shared Memory
- pshm/pshm_create.c (Listing 54-1)
- pshm/pshm_write.c (Listing 54-2)
- pshm/pshm_read.c (Listing 54-3)
- pshm/pshm_unlink.c (Listing 54-4)
Chapter 55: File Locking
- filelock/t_flock.c (Listing 55-1)
- filelock/i_fcntl_locking.c (Listing 55-2)
- filelock/region_locking.c (Listing 55-3)
- filelock/region_locking.h (Header file for Listing 55-3)
- filelock/create_pid_file.c (Listing 55-4)
- filelock/create_pid_file.h (Header file for Listing 55-4)
Chapter 57: Sockets: UNIX Domain
- sockets/us_xfr.h (Listing 57-2)
- sockets/us_xfr_sv.c (Listing 57-3)
- sockets/us_xfr_cl.c (Listing 57-4)
- sockets/ud_ucase.h (Listing 57-5)
- sockets/ud_ucase_sv.c (Listing 57-6)
- sockets/ud_ucase_cl.c (Listing 57-7)
- sockets/us_abstract_bind.c (Listing 57-8)
Chapter 59: Sockets: Internet Domains
- sockets/read_line.c (Listing 59-1)
- sockets/read_line.h (Header file for Listing 59-1)
- sockets/i6d_ucase.h (Listing 59-2)
- sockets/i6d_ucase_sv.c (Listing 59-3)
- sockets/i6d_ucase_cl.c (Listing 59-4)
- sockets/is_seqnum.h (Listing 59-5)
- sockets/is_seqnum_sv.c (Listing 59-6)
- sockets/is_seqnum_cl.c (Listing 59-7)
- sockets/inet_sockets.h (Listing 59-8)
- sockets/inet_sockets.c (Listing 59-9)
- sockets/t_gethostbyname.c (Listing 59-10)
- sockets/read_line_buf.c (Solution to Exercise 59-1)
- sockets/read_line_buf.h (Solution to Exercise 59-1)
- sockets/is_seqnum_v2.h (Solution to Exercise 59-2)
- sockets/is_seqnum_v2_sv.c (Solution to Exercise 59-2)
- sockets/is_seqnum_v2_cl.c (Solution to Exercise 59-2)
- sockets/unix_sockets.h (Solution to Exercise 59-3)
- sockets/unix_sockets.c (Solution to Exercise 59-3)
- sockets/us_xfr_v2.h (Solution to Exercise 59-3)
- sockets/us_xfr_v2_sv.c (Solution to Exercise 59-3)
- sockets/us_xfr_v2_cl.c (Solution to Exercise 59-3)
- sockets/t_getservbyname.c
Chapter 60: Sockets: Server Design
- sockets/id_echo.h (Listing 60-1)
- sockets/id_echo_sv.c (Listing 60-2)
- sockets/id_echo_cl.c (Listing 60-3)
- sockets/is_echo_sv.c (Listing 60-4)
- sockets/is_echo_inetd_sv.c (Listing 60-6)
- sockets/is_echo_v2_sv.c (Solution to Exercise 60-2)
Chapter 61: Sockets: Advanced Topics
- sockets/rdwrn.c (Listing 61-1)
- sockets/rdwrn.h (Header file for Listing 61-1)
- sockets/is_echo_cl.c (Listing 61-2)
- sockets/socknames.c (Listing 61-3)
- sockets/sendfile.c (Solution to Exercise 61-3)
- sockets/list_host_addresses.c
- sockets/scm_cred.h
- sockets/scm_cred_recv.c
- sockets/scm_cred_send.c
- sockets/scm_functions.c
- sockets/scm_functions.h
- sockets/scm_multi.h
- sockets/scm_multi_recv.c
- sockets/scm_multi_send.c
- sockets/scm_rights.h
- sockets/scm_rights_recv.c
- sockets/scm_rights_send.c
Chapter 62: Terminals
- tty/new_intr.c (Listing 62-1)
- tty/no_echo.c (Listing 62-2)
- tty/tty_functions.c (Listing 62-3)
- tty/tty_functions.h (Header file for Listing 62-3)
- tty/test_tty_functions.c (Listing 62-4)
- tty/demo_SIGWINCH.c (Listing 62-5)
- tty/ttyname.c (Solution to Exercise 62-2)
Chapter 63: Alternative I/O Models
- altio/t_select.c (Listing 63-1)
- altio/poll_pipes.c (Listing 63-2)
- altio/demo_sigio.c (Listing 63-3)
- altio/epoll_input.c (Listing 63-5)
- altio/self_pipe.c (Listing 63-9)
- altio/select_mq.c (Solution to Exercise 63-3)
- altio/epoll_flags_fork.c
- altio/multithread_epoll_wait.c
Chapter 64: Pseudoterminals
- pty/pty_master_open.c (Listing 64-1)
- pty/pty_master_open.h (Header file for Listing 64-1)
- pty/pty_fork.c (Listing 64-2)
- pty/pty_fork.h (Header file for Listing 64-2)
- pty/script.c (Listing 64-3)
- pty/pty_master_open_bsd.c (Listing 64-4)
- pty/unbuffer.c (Solution to Exercise 64-7)
Addendum Z: Supplementary material
- cgroups/alloc_mem.c
- cgroups/fork_bomb.c
- namespaces/cred_launcher.c
- namespaces/demo_userns.c
- namespaces/demo_uts_namespaces.c
- namespaces/hostname.c
- namespaces/multi_pidns.c
- namespaces/ns_capable.c
- namespaces/ns_child_exec.c
- namespaces/ns_exec.c
- namespaces/ns_run.c
- namespaces/orphan.c
- namespaces/pidns_init_sleep.c
- namespaces/show_creds.c
- namespaces/simple_init.c
- namespaces/t_setns_userns.c
- namespaces/unshare.c
- namespaces/userns_child_exec.c
- namespaces/userns_functions.c
- namespaces/userns_functions.h
- namespaces/userns_setns_test.c
- seccomp/dump_seccomp_filter.c
- seccomp/libseccomp_demo.c
- seccomp/seccomp_arg64.c
- seccomp/seccomp_control_open.c
- seccomp/seccomp_deny_open.c
- seccomp/seccomp_launch.c
- seccomp/seccomp_logging.c
- seccomp/seccomp_multiarch.c
- seccomp/seccomp_perf.c
- seccomp/seccomp_trap_sigsys.c
- seccomp/seccomp_user_notification.c
- vdso/gettimeofday.c
Copyright
http://man7.org/tlpi/code/online/all_files_by_chapter.html