Category: Recommendations

In college days, I heard about the init process. It is the root of process tree and first process started by the kernel and so on. I wanted to see what happens if we kill it. So I tried a lot but no success. Let’s kill the init process and observe what is happening

Note: Fedora switched systemd a while back, if you running Fedora you will find process “systemd” is with pid 1 instead of init.


Now, Years later I was reading Linux Kernel Development I was going through kernel sources mentioned in the book and all of a sudden I found the answer.

Note: File Paths mentioned here are relative to kernel source tree. I am using linux kernel 2.6.34.

In kernel/fork.c, in function copy_process(…) I found this

* Siblings of global init remain as zombies on exit since they are
* not reaped by their parent (swapper). To solve this and to avoid
* multi-rooted process trees, prevent global and container-inits
* from creating siblings.
if ((clone_flags & CLONE_PARENT) && current->signal->flags & SIGNAL_UNKILLABLE)
return ERR_PTR(-EINVAL);

Mark the above code as Listing 1. We know that operating system keep information about a process in process control block (PCB). In Linux, PCB is implemented as structure called task_struct declared in include/linux/sched.h. task_struct store all the important information about a process like it’s pid, memory mapping, signal mask etc…

Now, task_struct contains pointer to structure signal_struct named signal. Inside signal_struct field flags (unsigned int) refers to signal flags for the given process

struct task_struct {
signal_struct *signal

Form include/linux/sched.h
struct signal_struct {
unsigned int flags;      /* see SIGNAL_* flags below*/
#define SIGNAL_UNKILLABLE       0x00000040 /* for init: ignore fatal signals */

The above code (marked listing 1) prevents init from creating any siblings. In the above code current refers to the pointer  to task_struct for current process. init is the only process for which current->signal->flags is set to SIGNAL_UNKILLABLE. So, if init tries to create siblings using clone syscall, -EINVAL is returned.

Let’s see what happens when we remove the SIGNAL_UNKILLABLE flag from init. To do this I wrote a loadable kernel module. To learn how to write a loadable kernel module refer to

1. The Linux Kernel Module Programming Guide by Peter Salzman.

He also has a great tutorial on gdb you can find it on this link.

2. Book: Linux Device Drivers from O’REILLY.

Excerpt from the code.

/* Description: Remove UNKILLABLE flag from init */
static int hello_init(void)
struct task_struct *task;
    struct task_struct *init_ptr = NULL;
for (task = current; task != &init_task; task = task->parent) {
       init_ptr = task;
/* init_ptr now points to init, and task now points to init's parent i.e. swapper with pid 0 */
printk(KERN_ALERT "I am %s with pid %i\n", task->comm, task->pid);
printk(KERN_ALERT "I am %s with pid %i\n", init_ptr->comm, init_ptr->pid);
printk(KERN_ALERT "0x%x\n", init_ptr->signal->flags);

/* remove the UNKILLALBE flag */
init_ptr->signal->flags = init_ptr->signal->flags & ~SIGNAL_UNKILLABLE;
printk(KERN_ALERT "0x%x\n", init_ptr->signal->flags);
return 0;

When the above code is compiled, module hello.ko is generated. When we issue

“insmod hello.ko” command module initialization function hell_init is called.

When we insert the module using insmod command, current points to task_struct of insmod process, so in the for loop we keep on we keep on moving up the process tree until we encounter init_task as show in the picture below.

for (task = current; task != &init_task; task = task->parent) {
init_ptr = task;

Screen Shot 2013-08-16 at 8.20.04 PM

So, with first iteration we move from insmod to bash and so on until we reach init_task. Despite it’s name init_task is parent of init process and has pid of 0. It’s statically allocated and is not visible in user space.

Screen Shot 2013-08-16 at 9.14.20 PM

After that I am able to kill init using command “kill -9 1”. The moment I do kernel panics. I get core dump using kdump. Below is the dmesg output.

DMESG Output

NOTE: Since doesn’t allow you to create iFrames and manual code, We faced lot of issues while formatting this post. There are still issues with the alignment. We regret the inconvenience caused to you. Soon we will be moving to a personal domain and work for the same has already been started.


1. Manpages: man 7 signal, man ps

2. Linux Kernel Development By Robert Love

3. Linux Kernel Sources 2.6.34

4. Tools you may find useful: ctags, cscope, kdump.

Pages : Follow flossstuff on Twitter      

Few days back I attended a training given by Alexis Abril. It changed my thoughts about the JavaScript. Earlier my thought on JavaScript was “JavaScript is a scripting language just to manipulate HTML DOM elements mainly”.But after going through in-depth knowledge of JavaScript,I became a fan of JavaScript. It is not only document.getElementById , but it is a real programming language. Its prototype nature is really awesome. No doubts there are some flaws in the language but I think every language contains them. Context,prototype,functions are some of the remarkable features of this language.Moreover Javascript also possesses Object oriented nature but in a slight different manner. Libraries like JQuery,Dojo etc has further extended the capabilities of this language. I would recommend every web developer especially UI developers to learn this language in-depth. Few of the books I am following on the recommendation of Alexis Abril are JavaScript: The Definitive Guide 6th Edition and JavaScript: The Good Parts 1st Edition.. I would recommend readers to get the sixth edition of Definitive Guide because it includes HTML5 also. Second book is written by great Douglas Crockford and includes some advance JavaScript philosophies..

Pages : Follow flossstuff on Twitter      

I started writing for Linux For You Magazine in August 2010. Since Then I have written over 10 articles for this International Magazine. Today I am providing the readers with all the links to my articles. All the work done is under Creative Common License as described in the sidebar widget also.

1. Let’s Play With Emacs CLI : This teaches you the basics of the ‘Emacs’ Text Editor. This articles was published in the Aug 2010. I published it in two parts on my blog. Click on respective part numbers to read  : Part 1  Part 2  .

2.  Cut and Play With Pitivi Video Editor : A tutorial on how to use Pitivi video editor to play with videos in an experimental way. It was published in the Nov 2010 Edition.  Click to Read

3.  Let’s Play With Gnu Screen :  Tutorial about one of the greatest utility provided by GNU also know as ‘virtual terminal manager’ . It was published in Feb 2011 Edition . Click To Read

4. Get Started With Pygame Part 1 : One of my favorite series 🙂 It teaches you the basics about the pygame API of the python module. Pygame is the python extension of the SDL with some additional benifits. This article was published in May 2011. Click To Read

5. Get Started With Pygame Part 2 : Advance knowledge about the pygame API. Includes the color play and sprites usage tutorial . It was published in July 2011. Click To Read

6. Connection To Mysql With Python  and Php : Simple tutorial on how you can successfully connect mysql to your program of python or php. It was published in Aug 2011 . Click To Read

7. Recovered Deleted Files In Linux :  Different ways of recovering your deleted files using utilities like scalpel , foremost etc. It got published in Sep 2011 . Click To Read

8. Let’s Play With CodeIgniter Part 1 : Teaches you the basics of the PHP based framework ‘CodeIgniter’ . This frameworks is really useful and changes the way I used to code in PHP. It follows the MVC approach. It was published in the Oct Edition. Click To Read

There are certain articles like ‘Let’s Play With VirtualBox’,’Using Nessus and Metasploit’,’Play With GUI’s In Python’ that hasn’t been published  online yet . I will publish them in future on this blog and will provide you the links. So click on the links and explore the stuff 🙂

Pages : Follow ankurtwi on Twitter      

According to Ubuntu developers, the Ubuntu 12.04 (Long Term Support) has a new release schedule. There will be two Alpha versions, two Beta versions, then there will be a release of the Release Candidate version and finally the complete version will be released. It’s code name is “Precise Pangolin”. The schedule of the release of Ubuntu 12.04 with exact date is as follows.

Alpha 1 release date: December 1st 2011
Alpha 2 release date: February 2nd 2012
Beta 1 release date: March 1st 2012
Beta 2 release date: March 22nd 2012
Release Candidate release date: April 19th 2012
Ubuntu 12.04 Final release date: April 26th 2012

The Ubuntu 12.04 being a LTS release will be expected by many to be a strong OS with remarkable performance and support for features.

Pages : Follow ankurtwi on Twitter      

First Views On Google+

Yesterday I got the Invitation of the recently launched social networking site know as “Google+” . Its based on your day to day interaction analysis made by ex-Googler Paul Adams.  People are in high hopes that this will save them from the addiction of Facebook.  As of present it’s access is limited to few people only and it’s in testing phase. Due to excessive demand of invitations, Google has closed down the invitation part for sometime . It’s quite true because all I saw yesterday on Facebook and Twitter is “Please Invite Me to Google+”. Experts says that Google+ will get open for  public in the coming week. It’s available for Gmail users only as of now. Google+ account gets integrated with the other Google products. You can open it from various ways. Either hit the “+ANKUR” on your Google bar or login to the .

You can click on Google+ (+ANKUR)

As soon as you login you will see a very simple and attractive UI 🙂 Below is the screenshot of my plus account welcome screen.

Welcome Screen

Let’s talk about some of it features now :

1. You can easily add to contacts to the circles. Then while sharing ,you chooses the circle you want to share with. If you want to share it with all you have the public options for it. You can easily edit your circles.

2. It has got it recently launched “+1” button on very post and comment. It’s quite similar to the Facebook’s like button.

3. Notifications will appear on the top right side of the screen. You can also see it in the above screenshot.

4. Instead of wall post, you share the “Stream” with your circles.

5. It has got the “Spark” feature . It’s quite similar to the hashtag feature of the social micro blogging site Twitter. This features lacks in the Facebook. You just type your topic and sparks and all the streams related to that will appear on your screen.

6. One more good feature is you can edit your comments. Facebook needs to think about applying this feature as soon as possible 🙂

Spark Feature

Overall I think Google+ is great in the privacy field. Moreover sharing the post with the people you want to is one of its major strength.  There is also a data liberation option in your Google+  settings through which you can download all of  your  uploaded data.  I am still searching about it’s hangout feature and will try write about it soon 🙂 Feedbacks and Comments are welcome 😀 Oh!!!! I forgot to tell you one important thing i.e. Google+ is for 18+ only 😦

Pages : Follow ankurtwi on Twitter      

I am reading this book – “Unix concepts and applications” written by the great author “Sumitabha Das”. This book is very good to start from the basics. If you wanna buy it , you can purchase it from Buy Unix Concepts And Applications from .

It is very difficult to remember each shell command, even experts get confused with them sometimes. There’s an inbuilt documentation called as Man pages in Unix/Linux which practically provides the documentation of every command. You just have to type “man command” (without Quotes). What man command does,it searches for the documentation of the given command and  display it on the shell through the pager program. Man documentation has been divided into several sections. As of present it is divided into 9 sections each having a collection of specific category. Sections are-

1. Executable programs or shell commands

2. System Calls

3. Library Calls

4. Special Files (Usually Found in /dev)

5.File Formats and Coventations

6. Games

7. Miscellaneous

8. System Admin Commands

9. Kernel Routines

Most of the commands are available in the section 1. When you call the man documentation such as   “man wc”  man will look for the documentation of the wc command in the sections starting from section number 1. As soon as it finds it, it will stop looking further and  will display the documentation of the wc from the section 1.  There are many commands which are available in the multiple sections of the man documentation. For example passwd command is available in both section 1 and section 4. To locate the documetation section wise you should type the section number as an argument. Ex- “man 4 passwd” . This will display the man page of passwd form the section 4 not from the section 1.

Pages : Follow ankurtwi on Twitter      

If you are interested in knowing how an operating system works this book “Operating systems” By “Gary Nutt” is a great source of reading. I just started reading it and already got impressed with the way things are presented in the book. It covers all the topics from system tools to applications tools. Moreover it covers many of the platforms of the present and the past like Unix,Linux,BSD,windows,MacOsX. A must read for all 🙂 I searched the web for ebbok but unable to find it so,I bought it through flipkart. Here’s the link of the same Buy Operating Systems 3rd Ed. from

I would also like to recommend you guys this great book which not only motivates you but also teaches you important aspects of the Technical world. If you are passionate about Google like me you must read it :D:D Buy The Google Story from

I am reading about Pygame a lot these days. Was looking for a good book and found this one 🙂 It’s simply great 🙂 Buy Game Programming: The L Line 1st Edition from

And if you are crazy enough about the design patterns, This book will be your best partner  Design Patterns: Elements Of Reusable Object-Oriented Software....

Pages : Follow ankurtwi on Twitter      

%d bloggers like this: