- Claudio Neves <[EMAIL PROTECTED]>:

| Hello,
| 
| I know this was discussed here already, but I'm getting trouble when giving
| svc -h /var/run/qmail . Here is what I've put on my /etc/rc.d/rc.local:
| 
| csh -cf '/usr/local/bin/supervise /var/run/qmail /var/qmail/rc &'
| 
| And I have the following on /var/qmail/rc :
| 
| exec env - PATH="/var/qmail/bin:$PATH" \
| qmail-start ./Maildir/ /usr/local/bin/accustamp \
| | /usr/local/bin/setuser qmaill /usr/local/bin/cyclog -s 10000000 -n 10 \
| /var/log/qmail

Well I think this is fundamentally flawed:  When sh runs a pipeline,
it forks a subprocess for each component.  Adding exec does not change
this fact, so when sh runs ``exec foo | bar'' then the it forks to
shells; first subshell runs exec foo, and the other one runs bar (with
an implicit exec).  Thus supervise ends up controlling not qmail-send
in your case, but the waiting shell.

| When I give svc -h /var/run/qmail, I got the famous message "alert:
| cannot start: qmail-send is already running" everytime on the logs.

You just killed the waiting shell, so supervise started a new one.

In order to solve this sort of problem, I created a program I call
pipe.  You could use it to start qmail as follows:  Let /var/qmail/rc
contain

#!/bin/sh
exec pipe qmail-start ./Maildir/ /usr/local/bin/accustamp \
          '|1+2>0' /usr/local/bin/setuser qmaill \
                   /usr/local/bin/cyclog -s 10000000 -n 10 /var/log/qmail

That '|1+2>0' is pipe magic.  It pipes file descriptors 1 and 2 of one
program into file descriptor 0 of the next one.

I put pipe up for grabs at <URL:http://www.math.ntnu.no/~hanche/prog/pipe/>.

- Harald

Reply via email to