Re: [AD] Magic main on POSIX systems

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


Hein Zelle wrote:

> Perhaps someone with more knowledge of /proc systems can shed some
> light on this, my knowledge is insufficient.

Thanks to Laurence Withers for the tip:

on IRIX I found some documentation on the use of the /proc
filesystem. Using ioctl() calls it should be possible to request a
PIOCPSINFO code, which should return just about all the information ps
would give you about a process. This includes the 'last component of
exec()ed pathname', presumably just the executable name without path.

SunOS has a set of programs (pfiles, pinfo etc) which do a similar
thing, so I imagine it has a similar system for getting this
information out of the /proc filesystem using c function calls.

I'll try if I can write a program in my off-time which tries to
retrieve its own executable name using these /proc and ioctl tricks. I
don't think it's trivial, but it should be possible. Small point of
doubt remains when a process wants to retrieve it's own information:
the man page mentions something about processes being stopped when
this information is requested, and deadlocks becoming a possibility
;-)

Hein Zelle

>-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-< 
 Unix is user friendly. It's just very particular about who 
 it's friends are.

 Hein Zelle                     hein@xxxxxxxxxx
	                        http://www.icce.rug.nl/~hein
>-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-<



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