Deutsch   English   Français   Italiano  
<v8pq8u$h6kb$2@dont-email.me>

View for Bookmarking (what is this?)
Look up another Usenet article

Path: ...!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: Rene Kita <mail@rkta.de>
Newsgroups: comp.unix.shell
Subject: Re: Basic ps Tips
Date: Mon, 5 Aug 2024 06:08:30 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 46
Sender: Rene Kita <kt@ob.rkta.de>
Message-ID: <v8pq8u$h6kb$2@dont-email.me>
References: <v81fmh$32fuh$5@dont-email.me> <v8bja7$16ghh$1@dont-email.me> <v8h8ne$2eq4k$1@dont-email.me> <v8kl22$3ajo6$1@dont-email.me> <v8l5rk$3e995$1@dont-email.me> <v8ljlg$3gs0o$1@dont-email.me> <v8lpmb$3i4us$1@jmertens.eternal-september.org> <v8n8n4$3ugbk$1@dont-email.me> <v8nn26$1252$1@jmertens.eternal-september.org>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Injection-Date: Mon, 05 Aug 2024 08:08:31 +0200 (CEST)
Injection-Info: dont-email.me; posting-host="519d53e75290e06f10db6418a2587a1d";
	logging-data="563851"; mail-complaints-to="abuse@eternal-september.org";	posting-account="U2FsdGVkX1/cQBE+45KiMBMorR9mGLMH"
User-Agent: tin/2.6.2-20221225 ("Pittyvaich") (OpenBSD/7.5 (amd64))
Cancel-Lock: sha1:EcY+bcqMDoNl2MTGwPNVLAtSAI0=
Bytes: 3420

Joerg Mertens <joerg-mertens@t-online.de> wrote:
> Rene Kita <mail@rkta.de> wrote:
>> Joerg Mertens <joerg-mertens@t-online.de> wrote:
[...]
>>> The error message also is printed, when you run ps with a valid
>>> flag plus some string, like `ps -a xyz´, so it seems to be independent
>>> of the `-C´-option.  Maybe it has to do with parsing of the old-style
>>> flags vs. the dashed ones.
>> 
>> You got me curious and I got my debugger out for my morning coffee.
>> 
>> The error message comes from a function kvm_openfiles, which is called
>> after the flag parsing is done. From a quick glance, this function takes
>> what looks like three file names. If the second one is NULL, it will
>> default to /dev/mem. Trying to open /dev/mem it will error out - which
>> could be due to me being on a VPS.
>> 
>> While the man page mentions kvm(3) in the SEE ALSO section, there is no
>> mentioning nor explanation what additional arguments can be passed to
>> ps.
> 
> As I understand it, `ps´ can not only be used to examine the processes
> of your currently running system, but also those of another system
> represented by an image file.  Normally you would use the `N´ option 
> plus a filename to tell ps to do this, but the original way seems to
> have been to just add the filename to the commandline as an additional
> argument.
> 
> Now when you call `ps xy´, the argument xy is interpreted as a string
> of old style options which can be written without dashes.  Some
> people still write `ps aux´ for example to look at their processes.

Guilty. :-)

> But when you write `ps a xy´ (or `ps -a xy´), xy is interpreted as
> a "kernel image to be examined" (see the first argument to
> kvm_openfiles(3)), which leads to the `permission denied´ error.
> 
> To get back to the `-C´ option - it is there for compatibility
> reasons with old scripts.  You can find the relevant commit message
> under http://cvsweb.openbsd.org/src/bin/ps/ps.c when you search for the
> string `-C´.

That's what I thought. I was just surprised that it's not documented.
But the man page seems to be silent about all old style things. Looks
like it's by design.