Path: utzoo!utgpu!water!watmath!clyde!att!osu-cis!tut.cis.ohio-state.edu!rutgers!apple!bionet!agate!ucbvax!decwrl!sun!pitstop!sundc!seismo!uunet!steinmetz!davidsen From: davidsen@steinmetz.ge.com (William E. Davidsen Jr) Newsgroups: comp.unix.questions Subject: Re: Login shell? Message-ID: <12423@steinmetz.ge.com> Date: 25 Oct 88 20:44:26 GMT References: <3ed799bc.103e8@hi-csc.UUCP> <13851@mimsy.UUCP> <511@imec.UUCP> <1529@solo9.cs.vu.nl> <314@uplog.se> Reply-To: davidsen@crdos1.UUCP (bill davidsen) Organization: General Electric CRD, Schenectady, NY Lines: 20 In article <314@uplog.se> thomas@uplog.UUCP (Thomas Hameenaho) writes: | One way of deciding wether or not the current shell is the login shell | is the fact that the name of the login shell is prependended with a '-'. | If for instance I run tcsh as my login shell it will be exec:ed with | -tcsh as argv[0]. Only in a trusted environment. I can change the strings in the exec call so that the first argument is not the same as the program name. A better way is to check the PPID if your system has a known PID for init. Other than that you're on your own, but remember if you want to run something like "ps" to use the full pathname, at least. Most of the techniques mentioned are highly useful in a well behaved environment in which you are trying to avoid initialization or some such, but less reliable in the case where someone may be tricking your program into thinking it's a login shell. -- bill davidsen (wedu@ge-crd.arpa) {uunet | philabs}!steinmetz!crdos1!davidsen "Stupidity, like virtue, is its own reward" -me