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.


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):
#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.
FYI, this is definitely an Apple-specific problem; my OpenBSD machine shows all args just fine. May definitely be a ps bug.
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!