Re: [AD] No more END_OF_MAIN on *nix!

[ Thread Index | Date Index | More lists.liballeg.org/allegro-developers Archives ]


> Revised patch attached. If procfs is not available or does not follow the
> layout of Linux, this uses ps -f to get the filename. This lists a load of
> junk we don't need, but the filename is always in the last column.
> Unfortunately, the number and layout of the columns seems to vary between
> platforms, so I parse the output from the right until I reach a blank
> character. This is theoretically unsound as the filename could contain a
> space character. If desired, I'll think of something clever to work around
> that one too. In practice, it'll probably be ok as it is.

How about using the first line to find where the last column starts, i.e.
search from the right for the space character before "CMD"?  I don't know
if that will always work either though.

However, there's another problem.  From the Solaris ps man page:

    "Under the -f option, ps tries to determine the command  name
     and  arguments given when the process was created by examin-
     ing the user  block.  Failing  this,  the  command  name  is
     printed, as it would have appeared without the -f option, in
     square brackets."

The square brackets are disturbing.  Further, if you run ps -f on a login
shell, you get an extra dash for free:

     UID   PID  PPID  C    STIME TTY      TIME CMD
   wangp 22243 22242  0 15:33:57 pts/120  0:00 -bash

This is all getting to be too complicated, I think.  We can also consider
adding a new function like al_set_argc_argv(), if get_executable_name() is
really that important.  Or we can deprecate it :-)

Peter





Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/