Vic said
> > I need to determine if my Linux program is running detached,
> > e.g. if it was launched by
> >   vfxlin
> > or
> >   vfxlin &
> 
> VFX isn't too keen on not having a console...
> 
> What I did was to run it through screen :-
Thank you for answering a question I didn't ask! The current 
version of vfxlin has changed! The question is how do I 
determine if a program is running in a terminal session or is 
detached in some way, e.g. by using & at the end of the command 
line? I need need to make this distinction in order to choose 
between I/O to the term/xterm device or launch a GUI console.
Under Kubuntu 9.04 at least, trying to open /dev/tty succeeds in 
both cases and fds 0,1,2 return true from isatty(). Similarly, 
ttyname() returns a name.
Stephen
-- 
Stephen Pelc, stephen@???
MicroProcessor Engineering Ltd - More Real, Less Time
133 Hill Lane, Southampton SO15 5AF, England
tel: +44 (0)23 8063 1441, fax: +44 (0)23 8033 9691
web: 
http://www.mpeforth.com - free VFX Forth downloads