LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 10-04-2005, 08:49 PM   #1
Eileen
Member
 
Registered: Oct 2004
Posts: 99

Rep: Reputation: 15
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!!!
 
Old 10-04-2005, 09:58 PM   #2
Eileen
Member
 
Registered: Oct 2004
Posts: 99

Original Poster
Rep: Reputation: 15
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!!
 
Old 10-04-2005, 10:00 PM   #3
Eileen
Member
 
Registered: Oct 2004
Posts: 99

Original Poster
Rep: Reputation: 15
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
 
Old 10-04-2005, 11:29 PM   #4
kjordan
Member
 
Registered: Jul 2004
Distribution: LFS, I felt the itch and scratched it
Posts: 227

Rep: Reputation: 31
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.
 
Old 10-04-2005, 11:44 PM   #5
paulsm4
LQ Guru
 
Registered: Mar 2004
Distribution: SusE 8.2
Posts: 5,863
Blog Entries: 1

Rep: Reputation: Disabled
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
 
Old 10-05-2005, 12:21 AM   #6
Eileen
Member
 
Registered: Oct 2004
Posts: 99

Original Poster
Rep: Reputation: 15
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!!
 
Old 10-05-2005, 06:52 AM   #7
kjordan
Member
 
Registered: Jul 2004
Distribution: LFS, I felt the itch and scratched it
Posts: 227

Rep: Reputation: 31
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.
 
Old 10-05-2005, 07:09 PM   #8
Eileen
Member
 
Registered: Oct 2004
Posts: 99

Original Poster
Rep: Reputation: 15
Okey Dokey! I feel more rest assured now after hearing from the experts here. Thanks alot!! Have a nice day today!!
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
/var/run/[XXX].pid - Tcl pid code liguorir Linux - Software 1 05-20-2004 10:32 PM
rm cannot remove /var/run/atd.pid and /var/run/xdm.pid danishmr Linux - Software 1 05-04-2004 08:01 AM
ERROR: Couldn't write pid to pid file lawrencegoodman Linux - Newbie 2 02-13-2004 08:05 PM
Pid ck7802 Linux - Newbie 3 08-20-2003 11:22 AM
Large drive- too much space lost by large block size? tome Linux - General 5 12-14-2001 01:32 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 04:40 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration