1832359 Members
2524 Online
110041 Solutions
New Discussion

process id 0

 
SOLVED
Go to solution
muthamilan
Frequent Advisor

process id 0

hi friends
i'm having 2 doubt.
1.what's the function for pid 0?(i think pid1 is init process id,but init parent id shows 0)
2.how to find background process?
Kindly gudie me.

Thanks&Regards
S.Muthu
5 REPLIES 5
Richard Pereira_1
Regular Advisor

Re: process id 0

i believe 0 is originally swapper and then init (1) begins and processes start up after in order.
Eric Antunes
Honored Contributor

Re: process id 0

Yes,

It's the swapper. If you want to see it execute:

ps -ef|grep 0|more

Each and every day is a good day to learn.
Bill Hassell
Honored Contributor
Solution

Re: process id 0

process ID = 0 is for swapper, a daemon that handles page-in and page-out activities when memory is full. init is used to manage the entries in /etc/inittab and also to inherit background processes that have been detached from their parent. The term "background" process is meaningful in relation to an interactive shell. Processes like daemons such as cron and swapper and inetd all run by themselves so they aren't really background. In a shell, you can start a process using the & character which detaches a process from the shell's terminal.


Bill Hassell, sysadmin
Muthukumar_5
Honored Contributor

Re: process id 0

1. swapper is parent process for init process and The swapper process is associated with process swapping and process working set trimming, and continous activity of the swapper is typically considered undesirable.

It is the special process which started at bootup and create init process.

2. We can identify the background process as,
jobs command.

Examaple:

sleep 100&
# jobs

It will give all the process there.

You can foreground to background and vice versa using bg and fg shell command.

See ksh man page for jobs part



Easy to suggest when don't know about the problem!
Bill Hassell
Honored Contributor

Re: process id 0

Actually, there is a much more accurate way to see a particular process ID:

ps -fp 0

The -p option allows you to list one or more process IDs. grep and ps don't produce clean results (there are a lot of "0" characters in ps -ef). ps actually has MANY useful options including -u , and the really useful -C -H and -o options. However, to access the XPG4 options (-H -C -o) you need to temporarily set a special variable: UNIX95. To save a lot of typing, I'll use alias in /etc/profile so all users will have access to the XPG4 features too:

alias ps="UNIX95= /usr/bin/ps"

(don't export UNIX95= as it affects certain programs and libraries, possibly changing results) To see the hierarchical relationship of all processes:

UNIX95= ps -efH

To find all POSIX shell processes:

UNIX95= ps -fC sh

MUCH more accurate than grep.


Bill Hassell, sysadmin