Nolan Darilek writes: > I'm now about to encounter something, and was wondering if some of you > more experienced coders could give me some advice. Is there some way > of determining which program is running in the foreground? E.g. If > someone is at the shell prompt, I'd like to somehow know that > /usr/bin/tcsh is running in the foreground. On linux, getsid(0) will give you the "session id", which I think is the process id of the "session leader", which is usually the shell. Then you could use that number to read /proc/NNN/cmdline to get the shell name. > I was told that there was no standard way of doing this, but I was > wondering if anyone had another opinion? As far as I know, getsid() is linux specific. /proc too. > Are there any functions that I can use for this purpose? getppid() gets the parent process ID. This is more portable, but may not work in some situations (because of forking). Anyway hope that helps. Cheers, ___________________________________________________ \ / Andrew Apted <ajapted@xxxxxxxxxxxxxxx> \/