Skip to main content

Posts

Running long background processes with double fork magic

Note: In the following post child process is the process created after first fork() and grand child process is the process created after second fork().    In one of my projects recently I had to run a shell command as a background process. The system was performance intensive, so I had to run a child process and continue execution on the parent process.            We were using Python on Ubuntu so initially it seemed very easy. I thought of just using the subprocess library available for python. I started a background process with subprocess.Popen() and not call a Popen.wait() for it because I had to run the shell command in the background. PROBLEM:            Initially I thought it worked but when I checked the process tree. I noticed that the child processes completed  and entered a < defunct> state were not releasing memory.  SOLUTION:           After ...
Recent posts

Wrestler who became a saint

Junaid Baghdadi earned his livelihood as a professional wrestler. As was the norm, the Leader of Baghdad announced one day, "Today, Junaid Baghdadi will demonstrate his skills as a wrestler, is there anyone to challenge him." An elderly man shakily stood up with his neck quivering and said, "I will enter the contest with him." Whoever was witness to this scene could not contain themselves, they burst out howling with laughter, clapping their hands. The King was bound by the law. He could not stop someone who of his own free will entered the bout. The elderly man was given the permission to enter the ring. He was about sixty-five years old. When Junaid Baghdadi entered the ring, he was dumbfounded as was the King and all the spectators of the Kingdom who were present. The single thought that occupied their minds was, "How will this old man be able to fight?" The old man addressed Junaid with these words, "Lend me your ears." He then whispered, ...

Strings Album "30" - Track 01 - Sajni - 2018

Video is property of their respective owner.

Strings Album "30" - Track 02 - Urr Jaon - 2018

Video is property of their respective owner.

Quotations by me

It is so sad that humans are not as dynamic and vibrant as the rhythms and energy around them           Islamabad- 13-12-2016 Commit an extreme act and you will divide people in two groups. One cheering in favor and one condemning the act strongly. Now support the narrative you want to be popular.           Islamabad- 21-3-2018

Calculating 32 bit port masks through Python

Recently I had to work with openvswitch to apply drop some VIP traffic on some particular IPs. The problem was that those particular IPs had port ranges and the job was to only block those particular IP addresses with a specific port range. Openvswitch does not allows to specify port ranges like numbers, so if i were to add a rule for port range e.g 7 to 14 I cannot specify it like 7 - 14. Instead, I must specify the first number and wildcard the port numbers until the least significant 1 of the number changes to 0. For example: Number            Binary           Number of trailing 0s            Covered Range               Port Mask      7                    0111                              0    ...

Hack The Box - Invite Challenge

Hack The Box is an online platform allowing you to test your penetration testing skills and exchange ideas and methodologies with other members of similar interests. It contains several challenges that are constantly updated. Some of them simulating real world scenarios and some of them leaning more towards a CTF style of challenge. As an individual, you can complete a simple challenge to prove your skills and then create an account, allowing you to connect to our private network (HTB Labs) where several machines await for you to hack them. By hacking machines you get points that help you advance in the Hall of Fame.            I have started to solve the challenges one by one.                                        Website Link: https://www.hackthebox.eu                   To take Challenges you must registe...