The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > High Level Programming
Google UNIX.COM


High Level Programming Post questions about C, C++, Java, SQL, and other programming languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Determine Number of Processes Running wayne1411 Shell Programming and Scripting 4 12-17-2007 12:06 PM
Running a program on boot! D-Lexy UNIX for Dummies Questions & Answers 4 12-04-2002 02:14 PM
Running a program perleo UNIX for Dummies Questions & Answers 3 08-23-2002 07:34 AM
Running a program automatically jvadn0 Shell Programming and Scripting 3 03-12-2002 01:38 AM
Running a compiled Program Krebsbac High Level Programming 2 09-07-2001 01:39 PM

Reply
 
Submit Tools LinkBack Thread Tools Display Modes
  #8  
Old 06-30-2006
...@...
 

Join Date: Feb 2004
Location: NM
Posts: 4,274
All I'm saying is that ps on some systems invokes kernel mode code. I agree that spawning a process for this from C is a bad idea, but until the OP learns internals and systems calls he cannot get away from ps..
Reply With Quote
Forum Sponsor
  #9  
Old 07-02-2006
Technorati Master
 

Join Date: Mar 2005
Location: Large scale systems...
Posts: 2,610
Quote:
Originally Posted by jim mcnamara
All I'm saying is that ps on some systems invokes kernel mode code. I agree that spawning a process for this from C is a bad idea, but until the OP learns internals and systems calls he cannot get away from ps..

get the processid, and send signal-0 to that processid
if return value is equal to 0, process is available else its not available,

here there is no need to spawn a process with system call,

isn't this better ???
Reply With Quote
  #10  
Old 07-02-2006
Technorati Master
 

Join Date: Mar 2005
Location: Large scale systems...
Posts: 2,610
Quote:
Originally Posted by Hitori
I dont think that executing the shall command "ps -ef | grep 'job_name' | grep -v grep" is the best idia to solve this task. There are must be appropriate solution in C. (I've used Linux in general and prefer to use /proc)
else,
if you dont accept what Jim said,

i believe you should read the kernal internal data structure- process table as such ... which is done by ps.

And the code should itself switch to kernal mode to become permissible to read the process table and its entries
Reply With Quote
  #11  
Old 07-02-2006
Hitori's Avatar
Registered User
 

Join Date: Jun 2006
Posts: 360
Quote:
Originally Posted by matrixmadhan
else,
i believe you should read the kernal internal data structure- process table as such ... which is done by ps.
not all ps implementations do so

Quote:
Originally Posted by matrixmadhan
And the code should itself switch to kernal mode to become permissible to read the process table and its entries
Thanks, I'll try
Reply With Quote
  #12  
Old 07-02-2006
Technorati Master
 

Join Date: Mar 2005
Location: Large scale systems...
Posts: 2,610
Quote:
not all ps implementations do so
i didnt mean it that way...

my intention was just to say.. read the kernel data structure - process table and its entries

the usage ps is just an example and not a standard
Reply With Quote
  #13  
Old 07-16-2006
Registered User
 

Join Date: May 2006
Posts: 101
the unix programming faq contains sample programms for that. on linux it can be done by
searching /proc
Reply With Quote
Google The UNIX and Linux Forums
Reply

Tags
linux

Thread Tools
Display Modes




All times are GMT -7. The time now is 07:15 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008. All Rights Reserved.Ad Management by RedTyger Visit The Complex Event Processing Blog

Content Relevant URLs by vBSEO 3.2.0