Posts

Showing posts from February, 2026

Why isn't the child PID always parent+1 in fork()?

Issue: I noticed that the difference between the child and parent process' PIDs was different while running in Vim vs regular terminal. My code: #include<stdio.h> #include<unistd.h> int main() { pid_t child_pid; //pid_t is a data type used to represent a process id child_pid = fork(); printf("\n\nProcess: my PID is %d, and my parent is %d", getpid(), getppid()); if(child_pid 0) { printf("\nChild's pid = %d",getpid()); } else if(child_pid > 0) { printf("\nParent Pid %d",getpid()); } else { printf("fork failed"); return 1; } return 0; } Inside vim : Notice that difference between the parent and child ID is 6 -- not 1, as I had expected. # (1st time execution) Process: my PID is 10362, and my parent is 10164 Parent Pid 10368 Process: my PID is 10368, and my parent is 10362 Child's pid = 10368 Press ENTER or typ...

Fork Bomb Part 2: Controlled Chaos - Monitoring Resource Exhaustion in QEMU

Image
I ran a forkbomb in Debian VM, run on Hypervisor: QEMU Specs of VM- Cores: 2 RAM Memory: 20GB I had set up 3 monitoring environments beside it in my host OS- 1) htop (monitor CPU + Processes) 2) dmesg -w (monitor kernel messages) 3) vmstat 1 (monitor system level metrics - process stats, memory stats, swap, io, cpu breakdown) within 4 seconds, all 8 cores in my CPU were all running at full speed . Note: The cores that I assigned to the VM were virtual cores , but in reality, the all 8 cores of my machine were being used The Resource temporatily unavailable message has already started popping up. This means that the system has hit the process limit and cannot create new processes. The fork bomb's exponential growth: 1 second: ~32 processes 2 seconds: ~1,024 processes 3 seconds: ~32,768 processes (system-wide PID exhaustion) 4 seconds: Complete scheduler collapse I suspect that Ubuntu is reaching is cgroups limit. I will look into this more in the future...

How VSCode Secretly Handles Git Authentication (And I Reverse Engineered It)

Reason: Until now after setting up my git repo using git init , i would immediately open it in VS Code as a project and would run the git commands through the terminal in VS Code. So, in the previous post, [link] I noticed that setting up a private git repo on both termux and my laptop required SSH, and it required me to generate a public key and add that key to github. However, I had never needed to go through such a process while linking a local folder to Git. That made me wonder whether this was an issue with my git repo being private. So, I started looking into it. After exploring, I found out that, wheter private or public, to link a git repo to the local folder, you need either an SSH key or a PAT token to authenticate your laptop. PAT tokens are high security modern version of passwords. They are used when you want to link repo using http Git stopped allowing real passwords to be entered for command line actions in 2021. You must generate these in Github s...