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
script to monitor process running on server and posting a mail if any process is dead pradeepmacha Shell Programming and Scripting 12 10-17-2008 12:08 AM
Can a child process return a specific value to a parent process ? Ametis1970 High Level Programming 8 04-09-2008 08:22 PM
Killing of a process and send a mail if the process doesnot come up within 2 minutes Prince89 Shell Programming and Scripting 1 02-15-2008 04:10 PM
how to start a process and make it sleep for 5 mins and then kill that process shrao Shell Programming and Scripting 6 03-27-2007 09:54 AM
my process is going to sleep mode after 12 hours but i need my process in in firsy pr mukesh_rakesh1 UNIX for Advanced & Expert Users 0 09-04-2006 11:43 PM

Reply
 
Submit Tools LinkBack Thread Tools Display Modes
  #1  
Old 05-02-2005
vino's Avatar
Supporter (in vino veritas)
 

Join Date: Feb 2005
Location: Bangalore, India
Posts: 2,683
get process name from pid - getcommandline

All,

I have a requirement to get the process name of the newly execv'd process.

After getting the complete process name, I need to carry out further operations on that.

Problem so far is how do I retrieve the name of the process ?

There is an API in windows called GetCommandLine. I need something similiar to that in Linux.

I tried this forum and a whole lot of other google results. Nothing helped.

The best I have come up is Linux maintains a struct for each process, and a struct member supoosedly hold the process name. But I cant figure out which/what struct that is.

Any pointers will be appreciated.

Thanks,
Vino
Reply With Quote
Forum Sponsor
  #2  
Old 05-03-2005
Perderabo's Avatar
Unix Daemon
 

Join Date: Aug 2001
Location: Washington DC Area
Posts: 8,616
There is not any general way to do this unix. Each OS has different ways to handle it and some are very hard. You mention Linux though. With Linux, the info is in the /proc filesystem. To get the command line for process id 9999, read the file "/proc/9999/cmdline".
Reply With Quote
  #3  
Old 05-04-2005
vino's Avatar
Supporter (in vino veritas)
 

Join Date: Feb 2005
Location: Bangalore, India
Posts: 2,683
Perfect. This is what I was looking for !!

Thanks Perderabo !

Vino
Reply With Quote
Google The UNIX and Linux Forums
Reply

Thread Tools
Display Modes




All times are GMT -7. The time now is 05:51 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