image
image

Go Back   macosx.com > Mac Help Forums > Mac OS X System & Mac Software

Reply
 
LinkBack Thread Tools
  #1  
Old September 29th, 2001, 11:46 AM
Registered User
 
Join Date: Apr 2001
Location: Astoria, NY
Posts: 9
Thanks: 0
Thanked 0 Times in 0 Posts
snoozer is on a distinguished road
command args missing in 'ps' output

I've found the output of 'ps' does not always contain all the command-line arguments that were passed to a given process. Specifically, if any of the arguments has the form "-xxx=yyy", that argument and all arguments that follow it are missing from the 'ps' output.

The missing information screws up a script I'm using that pipes 'ps' to 'grep' and 'sed'. Presumably this script works in the Linux world, because that's where it was written. Is this a deliberate difference between BSD and Linux versions of 'ps', or is it just wacky like it seems to me?

(Note: giving 'ps' the -ww option does not help. This is not about widening the output. It seems that information actually is missing from whatever data structure Unix uses to list processes.)

Below is a code example that I submitted to Apple. I thought maybe folks here would know the answer offhand and could answer more quickly.

--Andy

==========
In one Terminal window, compile and run the enclosed C program as follows:
<pre> % cc dud.c<br> % ./a.out foo bar -x=y blah frog</pre>In another Terminal window, do a 'ps':
<pre> % ps -ax | grep a.out</pre>
You'll get something like this:
<pre> 386 p3 R+ 0:05.60 a.out foo bar</pre>
Here's the C program (dud.c):
Code:
#include &lt;stdio.h&gt;

int main(int argc, char** argv)
{
    int i;
    printf("%d args were given\n", argc);
    for (i = 0; i < argc; i++)
    {
        printf("arg[%d]: [%s]\n", i, argv[i]);
    }
    while (1)
    {
        // Do nothing forever -- use ^C to kill.
    }
}

Last edited by snoozer; September 29th, 2001 at 12:08 PM.
Reply With Quote
  #2  
Old September 29th, 2001, 01:05 PM
blb blb is offline
`'
 
Join Date: Apr 2001
Location: CO, USA
Posts: 651
Thanks: 0
Thanked 0 Times in 0 Posts
blb is on a distinguished road
FYI, this is definitely an Apple-specific problem; my OpenBSD machine shows all args just fine. May definitely be a ps bug.
Reply With Quote
  #3  
Old September 29th, 2001, 02:49 PM
Darkshadow's Avatar
wandering shadow
 
Join Date: Jul 2001
Location: DE, USA
Posts: 1,532
Thanks: 0
Thanked 0 Times in 0 Posts
Darkshadow is on a distinguished road
Heh, I wouldn't doubt it. I had a look at the source code they're using - it even has a variable named FIX_ME

Bad thing is, it wasn't even defined in the ps source anywhere!
Reply With Quote
Reply

Bookmarks

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
No sound output in OS X Jeremy Lee Mac OS X System & Mac Software 0 October 4th, 2002 07:31 AM
missing commands and other disasters jakez Unix & X11 4 September 16th, 2002 10:25 AM
missing commands and other disasters jakez Unix & X11 0 September 13th, 2002 12:50 AM
HW graphic acceleration was missing... ddma Apple News, Rumors & Discussion 10 April 21st, 2002 10:04 AM
UNIX related things... (tr, cut, awk, and permissions) simX Apple News, Rumors & Discussion 5 December 19th, 2001 03:33 AM


All times are GMT -5. The time now is 10:04 AM.


Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.3.0 RC1
Copyright 2000-2010 DigitalCrowd, Inc.