Deutsch   English   Français   Italiano  
<v8lpmb$3i4us$1@jmertens.eternal-september.org>

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

Path: ...!feeds.phibee-telecom.net!news.mixmin.net!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!jmertens.eternal-september.org!.POSTED!not-for-mail
From: Joerg Mertens <joerg-mertens@t-online.de>
Newsgroups: comp.unix.shell
Subject: Re: Basic ps Tips
Date: Sat, 3 Aug 2024 19:34:02 +0200
Organization: A noiseless patient Spider
Lines: 67
Message-ID: <v8lpmb$3i4us$1@jmertens.eternal-september.org>
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>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Injection-Date: Sat, 03 Aug 2024 19:34:05 +0200 (CEST)
Injection-Info: jmertens.eternal-september.org; posting-host="fd52e7130434360a2d6fe7d1a52b2dd3";
	logging-data="3740658"; mail-complaints-to="abuse@eternal-september.org";	posting-account="U2FsdGVkX1/JhIvaBPc/0RgQdH3DgOnWIWXcJm2nuU0="
User-Agent: tin/2.6.2-20221225 ("Pittyvaich") (OpenBSD/7.5 (amd64)) tinews.pl/1.1.61
Cancel-Lock: sha1:ybQpTazH4vhiwIwVkt+qjcs7gic=
Bytes: 3611

Rene Kita <mail@rkta.de> wrote:
> Ed Morton <mortonspam@gmail.com> wrote:
>> On 8/3/2024 2:08 AM, Rene Kita wrote:
>>> Jerry Peters <jerry@example.invalid> wrote:
>>>> Lawrence D'Oliveiro <ldo@nz.invalid> wrote:
>>>>> On Sat, 27 Jul 2024 00:40:49 -0000 (UTC), I wrote:
>>> [...]
>>>>>      ps -p$(pgrep -d, bash) -wwo pid,ppid,lstart,tty,etime,cmd
>>>>>
>>>>> says not to truncate the output, which is handy for long command lines.
>>>>   
>>>> Or just use ps -C <command>:
>>> [...]
>>>> Does noone know about -C? I keep seeing things like 'ps -ef | grep
>>>> <something> in scripts to see if <something is running, rather than
>>>> using 'ps -C'.
>>> 
>>> I did not know about it.
>>> 
>>> The man page on OpenBSD does not mention -C, but calling 'ps -C' does
>>> not give an error. But:
>>> #v+
>>> $ ps -C ksh
>>> ps: /dev/mem: Permission denied'
>>> #v-
>>> 
>>> Dunno what to make out of it, but apparently one reason to use grep
>>> instead of -C is portability.
>> 
>> Its described in the man page for FreeBSD ps, 
>> https://man.freebsd.org/cgi/man.cgi?ps(1), as:
>> 
>>     -C      Change  the  way         the  CPU  percentage is calculated by 
>> using a
>>            "raw" CPU calculation that ignores "resident" time  (this  nor-
>>            mally has no effect).
>> 
>> so maybe you're running FreeBSD instead of the OpenBSD version.
> 
> I'm pretty sure I know which version of BSD I'm running and I would be
> very surprised if OpenBSD would ship the FreeBSD version of ps...
> 
> But let's have a look at the source:
> #v+
>         while ((ch = getopt(argc, argv,
>             "AaCcefgHhjkLlM:mN:O:o:p:rSTt:U:uvW:wx")) != -1)
>                 switch (ch) {
>                 case 'A':
>                         all = 1;
>                         xflg = 1;
>                         break;
>                 case 'a':
>                         all = 1;
>                         break;
>                 case 'C':
>                         break;                  /* no-op */
> #v-
> 
> '-C' does nothing. I did not look further to see where that error is
> coming from.

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.

Regards