demasi@paisana.UUCP (05/27/87)
Hello Wizards, (male & female, alike) Here's an interesting problem (I think) I have a process which gets kicked off by a shell. This process (pure executable) depends upon the calling shell to set up its environment and create some named pipes. This process should run at all times while the machine (3b2/400, SV.2.0.4) is in multi user mode. Sounds like a good task for an inittab entry, correct? The only problem is that the process that must be kept continuously running is a background process, which gets called by the afformentioned shell, which croaks immediately after invoking the background process. Therefore, making an inittab entry for the invoking shell is useless. (Actually, it's a disaster, since the shell simply: 1) Sets up the background environment 2) Invokes the pure executable 3) Dies 4) Gets called again infinitely until init turns it off) Does anybody know of a way that I can get init to watch for the death of the Child process here and then have it call the invoking shell to restart said process? I already have an entry to restart the process once every time the machine enters multi-user, but I'm hoping for something to keep it moving. Waiting to hear from the net, -- Michael C. De Masi - AT&T Communications (For whom I work and not speak) 3702 Pender Drive, Fairfax, Virginia 22030 Phone: 703-246-9555 UUCP: seismo!decuac!grebyn!paisana!demasi "No matter where you go, there you are" - Buckaroo Banzai
jfh@killer.UUCP (05/29/87)
In article <90@paisana.UUCP>, demasi@paisana.UUCP (Michael C. De Masi) writes: > > Hello Wizards, (male & female, alike) Hello mere end user :-) :-) :-) > > Here's an interesting problem (I think) I have a process which > gets kicked off by a shell. This process (pure executable) depends > upon the calling shell to set up its environment and create some > named pipes. This process should run at all times while the machine > (3b2/400, SV.2.0.4) is in multi user mode. Sounds like a good task > for an inittab entry, correct? The only problem is that the process > that must be kept continuously running is a background process, which > gets called by the afformentioned shell, which croaks immediately > after invoking the background process. Therefore, making an inittab > entry for the invoking shell is useless. (Actually, it's a disaster, > since the shell simply: 1) Sets up the background environment > 2) Invokes the pure executable 3) Dies 4) Gets called again > infinitely until init turns it off) Two thoughts come to mind at this point. Write some more executable code to set up the environment, and then exec() your executable (or if you have the sources to your executable, mung on them so that it does the setup. Second thought, experiment with using "exec" in the shell. That may just do the trick. > Does anybody know of a way that I can get init to watch for the death > of the Child process here and then have it call the invoking shell to > restart said process? I already have an entry to restart the process > once every time the machine enters multi-user, but I'm hoping for > something to keep it moving. Yes, the trick however is that the child process _DOES_ die, and init detects it. Init knows nothing about what processes a process has started and doesn't (can't) wait for the children of a process to die - AND - know which process started them off. When your shell dies, the children of the shell are orphaned :-( how sad )-: and are inherited by init like any other orphan. Init wakes up and sees that one of its processes died and looks to see what action was specified in the inittab. Sounds like you are using respawn, so init recreates the process. Try one of the suggestions in the first paragraph, or failing there, change from respawn or ondemand to once. - John. Disclaimer - No disclaimer. Whatcha gonna do, sue me?
pls@sortac.UUCP (Pat Sullivan) (06/01/87)
In article <90@paisana.UUCP> demasi@paisana.UUCP writes: > ... This process (pure executable) depends >upon the calling shell to set up its environment and create some >named pipes. This process should run at all times while the machine >(3b2/400, SV.2.0.4) is in multi user mode. Sounds like a good task >for an inittab entry, correct? The only problem is that the process >that must be kept continuously running is a background process, which >gets called by the afformentioned shell, which croaks immediately >after invoking the background process. At the end of the shell invoked by init, "exec" your pure executable rather than throwing it in the background. The pure executable will then have the same process id as the shell had, and init will be happy because its child is still running. ============================================================ Pat Sullivan - {akgua|ihnp4}!sortac!pls - voice 404-257-7382
davidsen@steinmetz.UUCP (06/02/87)
I am probably missing something. Couldn't the invoking shell...exec...the background process? -- bill davidsen (wedu@ge-crd.arpa) {chinet | philabs | sesimo}!steinmetz!crdos1!davidsen "Stupidity, like virtue, is its own reward" -me
aeusemrs@csun.UUCP (06/02/87)
In article <90@paisana.UUCP> demasi@paisana.UUCP (Michael C. De Masi) writes: +--------- |Hello Wizards, (male & female, alike) |... This process (pure executable) depends |upon the calling shell to set up its environment and create some |named pipes. ... The only problem is that the process |that must be kept continuously running is a background process, which |gets called by the afformentioned shell, which croaks immediately |after invoking the background process. ... |Does anybody know of a way that I can get init to watch for the death |of the Child process here and then have it call the invoking shell to |restart said process? | |Michael C. De Masi - AT&T Communications (For whom I work and not speak) +--------- Michael, How `bout: 1) Having the shell script wait for the child itself, via wait. 2) Having the shell script execute it in the forground. 3) Have the shell program exec to the other program. 4) Make two programs, one that behaves the old way, and one that behaves as described above for use with inittab. -- Mike Stump, Cal State Univ, Northridge Comp Sci Department uucp: {sdcrdcf, ihnp4, hplabs, ttidca, psivax, csustan}!csun!aeusemrs
davel@hpisoa1.HP.COM (Dave Lennert) (06/08/87)
> > ..... Sounds like a good task > >for an inittab entry, correct? The only problem is that the process > >that must be kept continuously running is a background process, which > >gets called by the afformentioned shell, which croaks immediately > >after invoking the background process. > > At the end of the shell invoked by init, "exec" your pure executable > rather than throwing it in the background. The pure executable will > then have the same process id as the shell had, and init will be happy > because its child is still running. Not if the process forces itself into the background by forking and having the parent exit. I assume this must be the case, otherwise the shell script could just be changed to omit the "&" on the invocation of the program. (Granted an "exec" under such circumstances would work even better since it results in one less process.) -Dave Lennert HP ihnp4!hplabs!hpda!davel