LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   sh - large PID (https://www.linuxquestions.org/questions/programming-9/sh-large-pid-369830/)

Eileen 10-04-2005 08:49 PM

sh - large PID
 
Hi,

Previously I have posted the PID- large. Now I have solved it. But I noticed another problem related to PID when I view "top"

Here is the result:

# top

PID PRI NI SIZE RSS SHARE STAT LIB %CPU %MEM TIME COMMAND
10678 19 0 464 464 444 S 0 0.3 1.4 0:00 sh


In my program, I have used "system" commands to start running a few programs. Is this the cause?? How would I reduce this sh PID??


Could anyone please teach me??

Thank you very much!!!

Eileen 10-04-2005 09:58 PM

I searched the internet and books and realised that
system() function is related to sh -c call. Maybe this is why my sh PID is so large and continues to grow larger.

I am using system() to kick start running my 3 c.programs. This is what I did.


system("/usr/local/bin/test1");
system("/usr/local/bin/test2");
system("/usr/local/bin/test3");

The PID of test1, test2 and test3 are OK. But the
PID of sh is extremely big. Could someone please
teach me how to start running test1, test2 and test3 programs using system() with sh PID growing or some other ways to start running test1, test2 and test3??


Please help!!
Sincerely thank you for any help!!

Eileen 10-04-2005 10:00 PM

Sorry, I mean methods to start running test1, test2 and test3 programs using system() WITHOUT the sh PID growing so large.

Or any methods to kick start running my c programs

kjordan 10-04-2005 11:29 PM

Any particular reason the large PID is bothering you?

You can always try the good old fork(); exec(); calls to do it which is essentially what a system(); call does.

paulsm4 10-04-2005 11:44 PM

The numeric value of a PID ("1012" vs "100025") has no significance: don't worry about it.

Your previous post was about accidentally running "system()" in an infinite loop, inadvertantly spawning an excessive #/processes. That's bad. What PID a particular process is - it's not a problem!

'Hope that helps .. PSM

Eileen 10-05-2005 12:21 AM

Hi All!!

Thank you all for your kind reply!!

To kjordan:
I am suspecting my unit to be rebooted due to the large and growing PID of any process. The
pid has become 12447 for the top command, which means one of the processes PID keeps increasing. It should be the sh command. Will this be harmful to my unit like causing it to be rebooted??

To paulsm4,
Thanks for coming to my rescue again. Yeah, my previous post has been solved thanks to your advises. But now I am worried about the sh PID. :-(
I am a newbie in linux and worried that the way I
use system() is incorrect, causing the sh -c to have
increasingly large PID.

Could you all give me more advises!! Thank you very much!! Appreciate your great help!!

kjordan 10-05-2005 06:52 AM

How could any PID number be harmful to your computer? It's just a number to identify your process to any other process. I doubt there's any incorrect way to call system(); since it's just the name of the executable you want to execute. Don't worry about it, I've seen process numbers in the 20000's before I think. It's just a number assigned to it by the kernel.

Eileen 10-05-2005 07:09 PM

Okey Dokey! I feel more rest assured now after hearing from the experts here. Thanks alot!! Have a nice day today!!


All times are GMT -5. The time now is 05:42 PM.