On Sun, Aug 14, 2011 at 02:30:01AM -0500, Paul Elliott spake thus:
> On Saturday, August 13, 2011 10:36:28 AM Alan D. Salewski wrote:
> > Hi Paul,
*snip*

> >     convert-docs:
> >             unoconv --listener & \
> >             ucpid=$! ;\

edit:       ucpid=$$! ;\

> >             unoconv -f pdf some-document.odt  && \
> >             unoconv -f doc other-document.odt && \
> >             unoconv -f jpg some-image.png     && \
> >             unoconv -f xsl some-spreadsheet.csv ;\
> >             kill -15 $ucpid

edit:       kill -15 $$ucpid

 
> Here is what I did:
> #tricky code alert
> #in a subshell save pid of subshell, ($$$$) becomes $$ in subshell.
> #then exec the listener. result is listnener running 
> #in background with saved pid.
>         echo "echo "'$$$$'" >$@.pid ; exec unoconv --listener" | $(SHELL) &
> 
>       #A bunch of unoconv commmands here
> 
> #kill the saved pid, i.e. the listener. $$ becomes $ in the shell.
>         -kill $$(<$@.pid)
> #remove the pid save file
>         -rm $@.pid
> 
> The shell you are using must support $$,   ';' and exec for this to work.
> It this better or worse?

IMHO, worse. That's the approach I described as "gross" (see below),
with added complexity and resource use of an extra unneeded shell
process heaped on top:

 
> > One could store the pid value of the backgrounded 'unconv --listener'
> > process to a file, but since that's gross in this context I won't say
> > anything more about now that I've menioned that it's possible.

-Al

-- 
-----------------------------------------------------------------
a l a n   d.   s a l e w s k i                   salew...@att.net
1024D/FA2C3588 EDFA 195F EDF1 0933 1002  6396 7C92 5CB3 FA2C 3588
-----------------------------------------------------------------

Reply via email to