Stephen Gran on 6 Jan 2004 20:11:02 -0000 |
On Mon, Jan 05, 2004 at 10:00:47PM -0500, Michael C. Toren said: > On Mon, Jan 05, 2004 at 06:55:14PM -0500, Stephen Gran wrote: > > You're close, but a little off; the key is that when one program execs > another, the PID and PPID stay the same. [ snip some good stuff about how init works ] Cool. Thanks, that helped a lot, actually. > > If this is the case, then my first feeling, that a simple `if [ > > "$PPID" = 1 ]; then ...` should be fine. I was just worried that it > > couldn't be that simple because of my experimenting, and probable > > misinterpretation of how getty and login work. It even seems like > > $PPID works in dash, so hopefully it's portable enough. > > I don't see how testing to see if your parent process is init will give > you any insight into weather or not your script is being executed at boot > time or not, unfortunately. What if a user types "exec > /etc/init.d/whatever" from a console login shell? Well, that would actually be fine. The only thing I am trying to do is have the script run at boot, but not be rerun on upgrade. If a user wants to rerun it at any other time, and it's failing because they are doing it with exec from a login shell, I provide a manual-start that bypasses the $PPID check (I don't much care for the name, but that's window dressing). AFAICT, this test should work the way I'm hoping, because the $PPID during an upgrade run should be that of apt, and not init. -- -------------------------------------------------------------------------- | Stephen Gran | OK, so you're a Ph.D. Just don't touch | | steve@lobefin.net | anything. | | http://www.lobefin.net/~steve | | -------------------------------------------------------------------------- Attachment:
pgpzuJ5dzpehM.pgp
|
|