Operating System - HP-UX
1830997 Members
2598 Online
110018 Solutions
New Discussion

Process spawn multiple process

 
SOLVED
Go to solution
Thiyagarajan.s
Frequent Advisor

Process spawn multiple process

All,

Some script has been written in such a way that it spawns one process in backgroud
Some how there is muliple process created and each process has spawned to multiple and it went to create multiples of process

Can you please let me know how to kill all of them , Since there were some other process run by that user I don't want to kill all the process run by the user

Thanks for help
18 REPLIES 18
A. Clay Stephenson
Acclaimed Contributor
Solution

Re: Process spawn multiple process

Try this while su'ed as that user:

UNIX95=1 ps -fj

and note the Process Group ID(s) of the bad processes. Now use the negative value of the PGID rather than a PID in your kill command.

For example, if the "bad" PGID were 5000 then you would "kill -15 -5000 to kill all the members of that process group. If kill -15 fails then try kill -11.
If it ain't broke, I can fix that.
Sandman!
Honored Contributor

Re: Process spawn multiple process

At the very least a 'ps -ef | grep
~thanks
Thiyagarajan.s
Frequent Advisor

Re: Process spawn multiple process


Gurus

Sorry some how the machine was rebooted

Can you please let me know or where can I find out the funda behind UNIX95=1 ps -fj

Thanks
Patrick Wallek
Honored Contributor

Re: Process spawn multiple process

Read the 'ps' man page, especially the parts concerning the XPG4 options available.
Sandman!
Honored Contributor

Re: Process spawn multiple process

See ps(1) for details on UNIX95 and search this forum. It has some very informative posts on UNIX95 constructs and usages.

~hope it helps
A. Clay Stephenson
Acclaimed Contributor

Re: Process spawn multiple process

Just to make you fell really dumb, try "man ps". The UNIX95=1 simply sets the environment variable UNIX95 (in fact, "UNIX95=ps ..." will siffice because all that matters is that the UNIX95 environment variable be defined. If so, the XPG4 behavior of ps is triggered. I use "UNIX95=1 ps ..." because it leads to fewer (but not zero) dumb questions.
If it ain't broke, I can fix that.
Thiyagarajan.s
Frequent Advisor

Re: Process spawn multiple process


Seniors

Here are the some more things i need to justify

i) How can a user run a script , that will spawn multiples of process and make the system fully occupied ( even though ulimit was set )

ii) User has actually started the process but most of the process running with the PPID 1 ( how come this is possible )

I am just looking into things , I hope your input will be more helpful
Hein van den Heuvel
Honored Contributor

Re: Process spawn multiple process

Google for '+hpux +zombie'
Check man page for 'exit'.


My favourie way to quickly kill a bunch of similar commands is

$ ps -ef | awk '/comman[d]/{system ("kill -15 " $2)}'


The [x] in the awk regexp makes sure you don't shoot yourself in the foot.

Example below..


$ sleep 1000 &
[1] 9330
$ sleep 1000 &
[2] 9331
$ sleep 1000 &
[3] 9332
$ ps -ef | awk '/slee[p]/{system ("kill " i$2)}'
[3] + Terminated sleep 1000 &
[2] + Terminated sleep 1000 &
[1] + Terminated sleep 1000 &

Thiyagarajan.s
Frequent Advisor

Re: Process spawn multiple process


Thanks for input

But unfortunately i didnt get sufficient resource on this

Still i need to ask how can a zombi process can create another process ,
if suppose parent process creates some process then its childs can not be zombie(?)
becase parent is still alive and working

Can we conclude zombie process can only killed by reboot

How can one manage with such bombardment of process ( except reboot)
A. Clay Stephenson
Acclaimed Contributor

Re: Process spawn multiple process

A zombie process cannot spawn another process because a zombie process is not doing anything; a process could spawn another process and then become a zombie. It's impossible to kill a zombie process because the process is not running. Zombies comsume no resources and do no harm with one exception. A zombie occupies a slot in the kernel's process table; only in the case that you have so many zombies that that number begins to approach nproc is there any problem.
If it ain't broke, I can fix that.
Thiyagarajan.s
Frequent Advisor

Re: Process spawn multiple process


Thanks for response

will take scenario

while
do
While < infinite>
do
&
done
done
a) above parent runs and creates infinite process which is sleeping ( may be zombie )
b) parent got killed becaues of some reason and many of the process has ppid 1
c) there is recursive process creation because of some reason

Can we come out of the above with out reboot

Please suggest if above is not clear
Dennis Handly
Acclaimed Contributor

Re: Process spawn multiple process

>Can we conclude zombie process can only killed by reboot

You kill zombies by killing their evil parent. Of course you have to decide if the parent is worth more than cleaning up the process table.

>parent got killed because of some reason and many of the process has ppid 1

Then these zombies should be killed when their parent is reset to init.
Thiyagarajan.s
Frequent Advisor

Re: Process spawn multiple process


If suppose user is allowed to run a script
he can run some script which create potentially zombie background process and at the end make the system down

So UNIX can be made down by a normal user

I feel i am not making any sense above

Please let me know if false
James R. Ferguson
Acclaimed Contributor

Re: Process spawn multiple process

Hi:

> ...suppose user is allowed to run a script
he can run some script which create potentially zombie background process and at the end make the system down...So UNIX can be made down by a normal user...

The kernel imposes limits on a variety of resources. These limits are "fences" to prevent one process or one user from consuming an entire resource (memory, open files, etc.)

In the case of processes, the kernel 'maxuprc' parameter limits the maximum number of concurrent user processes per user while the 'nproc' parameter controls the overal, system-wide ceiling.

While 'maxuprc' doesn't limit 'root', one doesn't let the "normal" user run as root anyway!

Regards!

...JRF...
A. Clay Stephenson
Acclaimed Contributor

Re: Process spawn multiple process

You really need to leave zombies out of your question. They are a by-product of but not the cause of your problem. Any process that can spawn multiple other processes either by intent or accident, can bring the system to a crawl. It's very easy to do with mutally recursive shell scripts or a shell script which simply calls itself. Of course, shell scripts are the trivial example but it could be Perl, awk, or binary executables. You can protect the system to some degree by setting maxuprc which will limit the number of processes which can be run by a user.

The real fix to your problem is educating your users and developers.
If it ain't broke, I can fix that.
Thiyagarajan.s
Frequent Advisor

Re: Process spawn multiple process


James

normal user was not allowed , but accidentaly the process run by the user has ppid as 1

I always felt admin has control all thing if not i dont have words to say that even superdome can be - by single user
James R. Ferguson
Acclaimed Contributor

Re: Process spawn multiple process

Hi (again):

> normal user was not allowed , but accidentaly the process run by the user has ppid as 1

The fact that a process has a parental pid (ppid) of one (1) simply means that that process is now owned by 'init'. This will be the case seen when the parent of a process dies but its child remains alive --- 'init' inherits the child.

Regards!

...JRF...
Dennis Handly
Acclaimed Contributor

Re: Process spawn multiple process

>If suppose user is allowed to run a script
he can run some script which create potentially zombie background process and at the end make the system down

In general scripts can't create zombies, shells should prevent this. Only applications can. I'm not sure if perl gives the user enough rope to hang himself