Saturday 2 February 2019

linux - What do the [..] mean in 'ps' and how do you create a process like it?


When running ps, you get something like:


root         2  0.0  0.0      0     0 ?        S<   00:00   0:00 [kthreadd]
root 3 0.0 0.0 0 0 ? S< 00:00 0:00 [ksoftirqd/0]
root 4 0.0 0.0 0 0 ? S< 00:00 0:00 [events/0]

All the daemon processes generally have the '[..]' brackets around them.


What do they mean (if anything)? How do you create a process that appears like this?


The reason I ask is we create a system daemon from the rcS (the programme uses fork to create the daemon), but ps entry looks like:


root       207  0.0  0.2   1516   200 ?        S    00:00   0:00 /root/testdaemo

So we were wondering if it is important to have the '[..]' brackets and how processes get them in the first place.


Thanks.



Answer



Square brackets are used for processes that do not have an associated command line (mostly kernel threads and some system services).


If I recall correctly, you might be able to achieve the same effect for your process by setting argv[0] to the empty string.


No comments:

Post a Comment

Where does Skype save my contact&#39;s avatars in Linux?

I'm using Skype on Linux. Where can I find images cached by skype of my contact's avatars? Answer I wanted to get those Skype avat...