Saved searches
Use saved searches to filter your results more quickly
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session. You switched accounts on another tab or window. Reload to refresh your session.
🛠 Linux programming examples in C.
License
Lancher/linux-programming-examples
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Name already in use
A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Sign In Required
Please sign in to use Codespaces.
Launching GitHub Desktop
If nothing happens, download GitHub Desktop and try again.
Launching GitHub Desktop
If nothing happens, download GitHub Desktop and try again.
Launching Xcode
If nothing happens, download Xcode and try again.
Launching Visual Studio Code
Your codespace will open once ready.
There was a problem preparing your codespace, please try again.
Latest commit
Git stats
Files
Failed to load latest commit information.
README.md
Linux programming examples in C
- Use sbrk() to observe the process heap size ( program break ).
- Memory alignment please refer to Sven-Hendrik Haase — Alignment in C .
- Relation between real user ID(real uid, or ruid), the effective user ID (effective uid, or euid), and the saved user ID (saved uid, or suid).
- Privileged process can use setuid() to change three IDs to any value.
- Unprivileged process can use setuid() to change euid to the same value as ruid or suid.
- Please refer to paper Setuid Demystified for more details.
- Conversions between time() , gmtime() , localtime() , asctime() , ctime() and mktime().
- Process Time is divide to User CPU time (the time of the program access CPU) and System CPU Time (the time of kernel system call, page faults..).
- The read() and “write()` system calls don’t directly initiate disk access. Instead, they simply copy data between a user-space buffer and a buffer in the kernel buffer cache.
- Use inotify_init() and inotify_add_watch() to monitor files or directories.
- If signal number is equal to 0, means the kill() will only check if the process can be signaled.
- If the same signal is generated multiple times while it is blocked, then it is recorded in the set of pending signals, and later delivered, just once.
- The fork() allow one process, the parent, to create a child process. The child obtains the copies of stack, data, heap and text segments.
- File descriptors is also share between parent and child (use dup() ).
- The vfork() will not copy the parent process’s memory space until exec() or exit()`.
- Orphan process is parent process ended and child process keep running. The child process will adopt by INIT (pid==1) process.
- Zombie process is child exit before parent perform wait* operation. The Zombie process release almost all the resources but remains an entry in the kernel’s process table recording the child’s process ID.
- The zombies can NOT be killed by a signal, the only way to remove them from the system is to kill their parent.
# Kill the parent process of zombies. kill $(ps -A -o stat,ppid | awk '/[zZ]/')
Code | Descriptions |
---|---|
process_child.c | Create a child process. |
process_vfork.c | How vfork() is different from fork(). |
process_sig.c | Send signal from child to parent. |
process_exit_handler.c | Demonstrate the «atexit()» and «on_exit()». |
process_wait.c | Wait children. |
process_zombie.c | Create a Zombie process. |
- The simplest way to avoid d eadlocks is to define a mutex hierarchy. When threads can lock the same set of mutexes, they should always lock them in the same order.
- Thread-specific data is a technique for making an existing function thread-safe without changing its interface.
- Clear handlers will be called when the thread is canceled by pthread_cancel() .
Group process and control:
- A process group is a collection of related processes.
- A session is a collection of related process groups.
- Four types of Private File Mapping , Share File Mapping , Private Anonymous Mapping and Shared Anonymous Mapping .
About
🛠 Linux programming examples in C.