Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!tut.cis.ohio-state.edu!ucbvax!decwrl!pyramid!athertn!paul From: paul@athertn.Atherton.COM (Paul Sander) Newsgroups: comp.unix.wizards Subject: What shell is running? Keywords: sh csh differences w.r.t. programs Message-ID: <299@athertn.Atherton.COM> Date: 18 Feb 89 01:05:06 GMT Organization: Atherton Technology, Sunnyvale, CA Lines: 27 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@Atherton.COM | sys{op,adm,prg,engr} says {decwrl,sun,hplabs!hpda}!athertn!paul | "oops..." ?