Re: Process Id by Name.

2000-10-23 Thread guy keren


On Mon, 23 Oct 2000 [EMAIL PROTECTED] wrote:

> In addition to that, you should check the sources of top, which is ported
> to many unices, and you'll see how to parse /dev/kmem and such.
> Of course, don't use top from the procps utils - use the original
> from .
> I once had to write something similar, and top's sources were very helpful.

an important note regarding this: using the /proc file system interface,
as well as kmem and friends is not portable even between different
versions of the same OS. for example, the /proc file system interface was
completely re-written between solaris 2.5 and solaris 2.6, with the
backward compatibility mode mulfunctioning.

the same would most likely be the case with using kmem on HP-UX 10.20 and
11.00 (and older versions, if you need to support those) and probably
different linux versions as well. take that into account before choosing
the method of operation.

guy

"For world domination - press 1,
 or dial 0, and please hold, for the creator." -- nob o. dy


=
To unsubscribe, send mail to [EMAIL PROTECTED] with
the word "unsubscribe" in the message body, e.g., run the command
echo unsubscribe | mail [EMAIL PROTECTED]




Re: Process Id by Name.

2000-10-23 Thread didi

Hi

Nadav Har'El wrote:
> On Mon, Oct 23, 2000, Shlomi Fish wrote about "Re: Process Id by Name.":
> >..
> > AFAIK, ps uses the proc filesystem to gather information, at least on
> > Linux. So you might be able to use that.
> > 
> > I suggest you take a look at the source of the procps utilities. That of
> > course is assuming they are not Linux specific.
> 
> /proc and procps is quite Linux-specific, as far as I know. Solaris, for
> example, also has /proc/, but /proc/123456 has different files, and
> different directories. Other versions of Unix don't have a /proc filesystem
> at all, and their ps needs to read /dev/kmem (the Kernel memory) to do their
> job, which also means that 'ps' needs to be setuid root, and so you can't
> easily write a different ps program (not to mention you don't have the
> source ;)).
> 
> Parsing the output of the ps command is more portable, but note that there
> are 2 major variants of ps in the Unix world: BSD ps and System V ps. Solaris
> has them both (/bin/ps and /usr/ucb/ps) and Linux's ps is a wierd combination
> of both (depending on the options you give it).

In addition to that, you should check the sources of top, which is ported
to many unices, and you'll see how to parse /dev/kmem and such.
Of course, don't use top from the procps utils - use the original
from <ftp://ftp.groupsys.com/pub/top>.
I once had to write something similar, and top's sources were very helpful.

> 
> -- 
> Nadav Har'El|  Monday, Oct 23 2000, 25 Tishri 5761
> [EMAIL PROTECTED] |-
> Phone: +972-53-245868, ICQ 13349191 |In God we Trust -- all others must
> http://nadav.harel.org.il   |submit an X.509 certificate.
> 
> =
> To unsubscribe, send mail to [EMAIL PROTECTED] with
> the word "unsubscribe" in the message body, e.g., run the command
> echo unsubscribe | mail [EMAIL PROTECTED]
> 

bye,
didi


=
To unsubscribe, send mail to [EMAIL PROTECTED] with
the word "unsubscribe" in the message body, e.g., run the command
echo unsubscribe | mail [EMAIL PROTECTED]




Re: Process Id by Name.

2000-10-23 Thread Nadav Har'El

On Mon, Oct 23, 2000, Shlomi Fish wrote about "Re: Process Id by Name.":
>..
> AFAIK, ps uses the proc filesystem to gather information, at least on
> Linux. So you might be able to use that.
> 
> I suggest you take a look at the source of the procps utilities. That of
> course is assuming they are not Linux specific.

/proc and procps is quite Linux-specific, as far as I know. Solaris, for
example, also has /proc/, but /proc/123456 has different files, and
different directories. Other versions of Unix don't have a /proc filesystem
at all, and their ps needs to read /dev/kmem (the Kernel memory) to do their
job, which also means that 'ps' needs to be setuid root, and so you can't
easily write a different ps program (not to mention you don't have the
source ;)).

Parsing the output of the ps command is more portable, but note that there
are 2 major variants of ps in the Unix world: BSD ps and System V ps. Solaris
has them both (/bin/ps and /usr/ucb/ps) and Linux's ps is a wierd combination
of both (depending on the options you give it).

-- 
Nadav Har'El|  Monday, Oct 23 2000, 25 Tishri 5761
[EMAIL PROTECTED] |-
Phone: +972-53-245868, ICQ 13349191 |In God we Trust -- all others must
http://nadav.harel.org.il   |submit an X.509 certificate.

=
To unsubscribe, send mail to [EMAIL PROTECTED] with
the word "unsubscribe" in the message body, e.g., run the command
echo unsubscribe | mail [EMAIL PROTECTED]




Re: Process Id by Name.

2000-10-23 Thread Shlomi Fish

On Mon, 23 Oct 2000, Alexander Indenbaum wrote:

> Hi!
> 
> I'm writing c++ library which should find pid 
> by process "name" - command line.
> This library should work on Linux Solaris and HP-UX.
> How do I do it?
> 
>   Alexander Indenbaum
>   [EMAIL PROTECTED]
>

A naive solution would be to parse the output of ps. I'm not sure if the
ps output and flags are portable across these three platforms, but it's
probably the most portable solution I can think of.

AFAIK, ps uses the proc filesystem to gather information, at least on
Linux. So you might be able to use that.

I suggest you take a look at the source of the procps utilities. That of
course is assuming they are not Linux specific.

Regards,

Shlomi Fish
 
> 
> =
> To unsubscribe, send mail to [EMAIL PROTECTED] with
> the word "unsubscribe" in the message body, e.g., run the command
> echo unsubscribe | mail [EMAIL PROTECTED]
> 
> 



--
Shlomi Fish[EMAIL PROTECTED] 
Home Page: http://t2.technion.ac.il/~shlomif/
Home E-mail:   [EMAIL PROTECTED]

The prefix "God Said" has the extraordinary logical property of 
converting any statement that follows it into a true one.


=
To unsubscribe, send mail to [EMAIL PROTECTED] with
the word "unsubscribe" in the message body, e.g., run the command
echo unsubscribe | mail [EMAIL PROTECTED]




Process Id by Name.

2000-10-23 Thread Alexander Indenbaum

Hi!

I'm writing c++ library which should find pid 
by process "name" - command line.
This library should work on Linux Solaris and HP-UX.
How do I do it?

  Alexander Indenbaum
  [EMAIL PROTECTED]


=
To unsubscribe, send mail to [EMAIL PROTECTED] with
the word "unsubscribe" in the message body, e.g., run the command
echo unsubscribe | mail [EMAIL PROTECTED]