Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Get the command line of a process 1

Status
Not open for further replies.

Sergio76

Programmer
Jun 10, 2005
1
ES
Hi.

I have a program that will launch some processes. At a given time, other program may decide to kill some of the child processes of the original process. The trouble is that the logic used to know which processes to kill needs to know the command line arguments used to call them.

So far I have got to get the tree of the process children and grandchildren using getprocs, but I just found out that it does not return the process command line.

I have found that "ps -o args" shows the arguments, so they must be accessible somewhat, but I just do not know which system call use. I do not want to use ps because the system is going to be installed in other computers and I do not want it to depend of a particular implementation of ps. Also the ps documentation says that sometimes the args info just cannot be retrieved, but I would like to get to the actual system calls to know if they are more specific.

Thanks In Advance. Sergio.
 
I'm not sure system calls are going to be any more portable than "ps -o args" implementations.

Why not have the original process record the information in a file that the later process can examine? That way, you define the format of the file and it's totally portable. You could even use a coding scheme that would reduce the parsing load on the later process.





Rod Knowlton
IBM Certified Advanced Technical Expert pSeries and AIX 5L
CompTIA Linux+
CompTIA Security+

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top