Path: utzoo!utgpu!news-server.csri.toronto.edu!rutgers!cs.utexas.edu!uunet!ncrlnk!ncr-mpd!Chuck.Phillips From: Chuck.Phillips@FtCollins.NCR.COM (Chuck.Phillips) Newsgroups: comp.unix.internals Subject: Re: How to know your current shell from C code Message-ID: Date: 12 Sep 90 17:12:02 GMT References: <1990Sep11.164436.9592@cadence.com> Sender: uucp@ncr-mpd.FtCollins Distribution: usa Organization: NCR Microelectronics, Ft. Collins, CO Lines: 26 In-reply-to: mikel@cadence.cadence.com's message of 11 Sep 90 16:44:36 GMT >>>>> On 11 Sep 90 16:44:36 GMT, mikel@cadence.cadence.com said: mikel> Recently I had a UNIX question. I have a c program and I want to mikel> know which shell(sh,csh,ksh) is my parent. Is there any way to do mikel> this? Environment variable is not acceptable. There is always the kludge of calling getppid() for your parent's process ID, then examining the output of "ps" (given appropriate arguments) to find out what fired off your program. Note: If your C program has a shell script wrapper, _that_ is what you'll find, not the shell the user used. I _assume_ this is what you care about and not the user's shell, otherwise the SHELL environment variable probably would be a better approach. Even less portably, your program can run as SUID root or SGID kmem and wade through /dev/(k)mem for information. Have fun, Chuck Phillips MS440 NCR Microelectronics Chuck.Phillips%FtCollins.NCR.com 2001 Danfield Ct. Ft. Collins, CO. 80525 uunet!ncrlnk!ncr-mpd!bach!chuckp -- Chuck Phillips MS440 NCR Microelectronics Chuck.Phillips%FtCollins.NCR.com 2001 Danfield Ct. Ft. Collins, CO. 80525 uunet!ncrlnk!ncr-mpd!bach!chuckp