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

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


On Monday 02 August 2004 08:08, Peter Wang wrote:
> 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.

It would, if the first line were always the same. Unfortunately, I've seen 
both CMD and COMMAND listed as heading for the last column. No telling 
what else is possible if we allow for the possibility of alternate 
language versions of ps (don't know if those really exist though).
What could work is find the last column by starting right in the first 
output and walk backwards, as I now do for the second line of output. I'm 
going to look into that.

> 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. 

Yes. Possibly something that we could detect though...

> Further, if you run ps -f on a login
> shell, you get an extra dash for free:

Yeah, I saw that too. I figured it wouldn't be a real problem if Allegro 
programs are not run as a login shell. Worst case, we could detect that 
too.

> 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 :-)

I don't think it is that important, to be honest. It does have its uses 
though, especially in programs ported from Windows. I'm also not sure I 
like the idea of adding a new function to the API just for this... 
especially since most people who will encounter it will be on a Linux 
system where procfs is installed anyway...

Evert





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