What shell is running?

Paul Sander paul at athertn.Atherton.COM
Sat Feb 18 11:05:06 AEST 1989


How can a running program tell what shell spawned it?

Here is my problem.  I have a Curses-based application that must work
properly when its input, output, or both are redirected.  This program
must not coredump, even if the user does strange things like invoke it
interactively in the background.  But the Curses implementation I am
using likes to coredump under certain situations like this when running
under csh.

My workaround is to not permit the application to run at all when invoked
in the background under csh when either stdin or stdout is not redirected.
To determine which shell is running at the time, I am using a horrible
kludge:  Check the line discipline the tty driver is using; if its the new
discipline then assume csh, otherwise assume sh.  To determine background-
ness, I compare the tty's process group with my process id, and assume
background if they're different.

My system is a Sun 3, running SunOS 4.2 Release 3.2.  Has anyone else had
the problems I'm having, and is there a better way to determine which shell
is running?  And is there a better way to determine whether or not I'm
running in the background?

Many thanks in advance.
-- 
Paul Sander        (408) 734-9822       | Do YOU get nervous when a
paul at Atherton.COM                       | sys{op,adm,prg,engr} says
{decwrl,sun,hplabs!hpda}!athertn!paul   | "oops..." ?



More information about the Comp.unix.wizards mailing list