Path: utzoo!utgpu!water!watmath!clyde!att!osu-cis!tut.cis.ohio-state.edu!mailrus!uwmcsd1!marque!uunet!mcvax!hp4nl!philmds!leo From: leo@philmds.UUCP (Leo de Wit) Newsgroups: comp.unix.questions Subject: Re: Login shell? Message-ID: <842@philmds.UUCP> Date: 22 Oct 88 17:32:20 GMT References: <3ed799bc.103e8@hi-csc.UUCP> <13851@mimsy.UUCP> <511@imec.UUCP> <1529@solo9.cs.vu.nl> <314@uplog.se> Reply-To: leo@philmds.UUCP (Leo de Wit) Organization: Philips I&E DTS Eindhoven Lines: 24 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]. | |Just take the output from ps -x (or -f if on system V) grep for pid $$ |and check if the command name begins with a '-'. If that is the case the |shell is the login shell. Two problems: 1) When I execl("/bin/sh","-sh",(char *)0); from within a C program I also have a shell whose name starts with '-' (it will consequently try to read a .profile file in the current directory, have you ever tried that?). This is not a login shell (unless the C program is called login 8-). 2) When I exec a shell in my .profile file (for instance if I want my own shell instead of /bin/sh or /bin/csh and don't want to bother my system manager), this shell doesn't start with '-'. You could argue about it, but I would like to consider this a login shell (the other 'login shell' has in fact also little to do with login, except for the fact that it is exec'ed from login, but then, this one is too). Leo.