pipeline outlives TERMed bash

2005-09-14 Thread Denis Vlasenko
Hi!

I want to run this script continuously under supervise
(a tool for daemontools package):

user=daemon
exec env - \
softlimit \
setuidgid "$user" \
nmeter t c l i p lf b nifi nife d6' \
| logger -t ''

nmeter prints lines like this:

14:31:00 [UU] int  63k f 100 bio  96k  11M ifi  81k 1.1M ife 879k 192k

every minute, and I want them to be logged in syslog.

This works. However, I also want to be able to stop/[re]start
this script using daemontools' standard utility, svc:

svc -d: sends a TERM to running daemon
svc -u: starts daemon if it is not running

The problem is that svc -d (or manual kill -TERM)
kills bash but nmeter and logger continue to run,
until I kill nmeter manually.

(NB: running this script manually and pressing ctrl-C
kills all three processes. You need to kill bash
from another terminal to see this happen)

I need to run this crawling horror:

user=daemon
trap 'sh exit.sh' EXIT
sh -c 'echo kill $$ >exit.sh
exec env - \
softlimit \
setuidgid '"$user"' \
nmeter t c l i p lf b nifi nife d6' \
| logger -t '' &
wait

to get behaviour I want.

Is there a saner solution?
--
vda


___
Bug-bash mailing list
Bug-bash@gnu.org
http://lists.gnu.org/mailman/listinfo/bug-bash


Re: pipeline outlives TERMed bash

2005-09-14 Thread Denis Vlasenko
On Thursday 15 September 2005 00:51, Paul Jarc wrote:
> Denis Vlasenko <[EMAIL PROTECTED]> wrote:
> > The problem is that svc -d (or manual kill -TERM)
> > kills bash but nmeter and logger continue to run,
> > until I kill nmeter manually.
> 
> It's best not to put a long-running pipeline in a daemontools run
> script, for just this reason (among others).  Instead, move logger
> into a separate /service/foo/log/run script.
> http://cr.yp.to/daemontools/faq/create.html#runlog>

Thanks! It's so obvious really. Why it didn't occur to me?
--
vda


___
Bug-bash mailing list
Bug-bash@gnu.org
http://lists.gnu.org/mailman/listinfo/bug-bash


Re: pipeline outlives TERMed bash

2005-09-15 Thread Denis Vlasenko
On Thursday 15 September 2005 00:51, Paul Jarc wrote:
> Denis Vlasenko <[EMAIL PROTECTED]> wrote:
> > The problem is that svc -d (or manual kill -TERM)
> > kills bash but nmeter and logger continue to run,
> > until I kill nmeter manually.
> 
> It's best not to put a long-running pipeline in a daemontools run
> script, for just this reason (among others).  Instead, move logger
> into a separate /service/foo/log/run script.
> http://cr.yp.to/daemontools/faq/create.html#runlog>

Done.

But in cases where I can't avoid using a pipeline:
I find it unconvenient that there is no sane way to know PIDs
of individual pipeline members. Or is there?

$! returns PID of _last_ process in backgrounded pipeline,
but I want to know PID of first one.
--
vda


___
Bug-bash mailing list
Bug-bash@gnu.org
http://lists.gnu.org/mailman/listinfo/bug-bash