Stephen Gran on 5 Jan 2004 18:51:02 -0000


[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]

Re: [PLUG] How to find parent in the shell?


On Mon, Jan 05, 2004 at 01:38:38AM -0500, Michael C. Toren said:
> On Sun, Jan 04, 2004 at 11:11:19PM -0500, Stephen Gran wrote:
> > What I'm looking for is something like $PPID, or maybe $$, but that
> > gives me a little more information to work with,
> 
> To extract argv[0] of the parent, perhaps you could use:

[ snip many good ideas ]

> > and a way to make it be portable across the various implementations.
> 
> This is also entirely linux specific.  Or by implementations, did you
> mean distributions?

No, I mean init implementations.  As I understand it, the way Debian
does things is something like (SysV?) init, but there are other ways,
and many of them are available in Debian, so I should try to support
them.  file-rc is one, runit and minit are others, etc.  The one I am
familiar with calls each script in a directory in lexical order,
starting with rcS.d at boot, and then rc{runlevel}.d on entering and
leaving each run level.

I believe that file-rc has a master config file, specifying what scripts
are to be started and the order of them.  runit (and I think minit) both
use some sort of Makefile-like syntax.  So I'm hoping for some way to
find, with all of these different systems, that really init is the
caller of the script, although the implementation of _how_ the script is
called will vary from implementation to implementation.  I am just not
sure how to achieve this.  

The suggestions you and others gave me have given me a starting point,
but I wouldn't mind if someone who used a different init setup would
jump in with an idea or two - I have no way to test myself, and don't
really want to convert perfectly functional boxes over for testing
purposes.

-- 
 --------------------------------------------------------------------------
|  Stephen Gran                  | A computer without COBOL and Fortran is |
|  steve@lobefin.net             | like a piece of chocolate cake without  |
|  http://www.lobefin.net/~steve | ketchup and mustard.                    |
 --------------------------------------------------------------------------

Attachment: pgpYnzayjSscN.pgp
Description: PGP signature