Some questions around spawn

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Some questions around spawn

Clement Thomas
Hi,
    I am writing a simple lookup script in python and i use spawn to make it talk to postfix.

# /etc/postfix/master.cf
127.0.0.1:6543 inet  n       n       n       -       0      spawn
  user=nobody   argv=/opt/scripts/lookupserver
# connecting as tcp:localhost:6543

and it works as expected. but i have a couple of questions around it.

* what is the use of transport_time_limit? postfix docs say that it is the amount of time the command is allowed to run before it is terminated. The transport_time_limit is set to 10 seconds for testing. but the program is not terminated after 10 seconds but a message is logged by spawn that command time limit exceeded. Is the process expected to exit by itself after sometime?

* what happens when we stop postfix. Will spawn be notifying the children with some signals? What all signals is the script expected to handle?



Regards,
Clement
Reply | Threaded
Open this post in threaded view
|

Re: Some questions around spawn

Wietse Venema
Clement Thomas:

> Hi,
>     I am writing a simple lookup script in python and i use spawn to make
> it talk to postfix.
>
> # /etc/postfix/master.cf
> 127.0.0.1:6543 inet  n       n       n       -       0      spawn
>   user=nobody   argv=/opt/scripts/lookupserver
> # connecting as tcp:localhost:6543
>
> and it works as expected. but i have a couple of questions around it.
>
> * what is the use of transport_time_limit? postfix docs say that it is the
> amount of time the command is allowed to run before it is terminated. The
> transport_time_limit is set to 10 seconds for testing. but the program is
> not terminated after 10 seconds but a message is logged by spawn that
> command time limit exceeded. Is the process expected to exit by itself
> after sometime?

The spawn(8) daemon sends SIGKILL to the child process. This signal
cannot be ignored.  Therefore, the child has changed process ID by
invoking fork() somewhere inside some "run in the background as a
daemon" function. Don't do that.

        if ((err = timed_waitpid(pid, &wait_status, 0, args.time_limit)) < 0
            && errno == ETIMEDOUT) {
            msg_warn("%s: process id %lu: command time limit exceeded",
                     args.command, (unsigned long) pid);
            kill(-pid, SIGKILL);
            err = waitpid(pid, &wait_status, 0);
        }

> * what happens when we stop postfix. Will spawn be notifying the children
> with some signals? What all signals is the script expected to handle?

The signal is sent to all processes in the Postfix master's process
group.  That does not work if your child process changes process
group, perhaps as part of some "run in the background as a daemon"
function.  Don't do that.

        Wietse