Eray Aslan:
> On Tue, Apr 03, 2018 at 07:46:42PM -0400, Wietse Venema wrote:
> > I updated both the postfix-script file and the master daemon.
> >
> > I'd appreciate it if someone could verify that this will run the
> > master daemon with PID 1, and that 'postfix stop' in the container
> > will stop the master daemon. If it doesn't, then Linux does weird
> > stuff with PID 1 processes.
Thanks for the detailed reports.
> Unless I am missing something, postfix stop does not stop the master
> daemon inside a container:
Confirming that Linux does weird stuff with signals and PID 1 processes
(it ignores the equivalent of "kill -9 myself" that I added to the code).
> $ docker exec a49e9ce8d75d ps aux
> USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND
> root 1 0.0 0.1 71540 2876 ? Ss 14:52 0:00
> /usr/libexec/postfix/master -i
> postfix 76 0.0 0.1 71524 2832 ? S 14:52 0:00 pickup -l -t
> unix -u
> postfix 77 0.0 0.1 71572 2864 ? S 14:52 0:00 qmgr -l -t
> unix -u
> root 78 0.0 0.0 17556 1184 ? Rs 14:52 0:00 ps aux
That looks as intended: the master runs with PID 1.
> USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND
> root 1 0.0 0.0 188 4 ? Ss 14:48 0:00
> /usr/local/bin/dumb-init postfix start-fg
> root 5 0.0 0.0 18352 1696 ? Ss 14:48 0:00 /bin/sh
> /usr/libexec/postfix/postfix-script start-fg
> root 77 0.0 0.1 71540 2880 ? Ss 14:48 0:00
> /usr/libexec/postfix/master
> postfix 78 0.0 0.1 71524 2836 ? S 14:48 0:00 pickup -l -t
> unix -u
> postfix 79 0.0 0.1 71572 2864 ? S 14:48 0:00 qmgr -l -t
> unix -u
And that looks as expected when master is not running as PID 1.
> $ docker exec 172645c305b8 postfix stop
> $ docker ps
> CONTAINER ID IMAGE COMMAND CREATED
> STATUS PORTS NAMES
>
> i.e. no running container after postfix stop.
The dumb-init program terminates after 'postfix start-fg' terminates.
if (killed_pid == child_pid) {
forward_signal(SIGTERM); // send SIGTERM to any remaining children
DEBUG("Child exited with status %d. Goodbye.\n", exit_status);
exit(exit_status);
}
I.e. no Linux-specific hackery.
Just for the heck of it, can you replace in src/master/master_sig.c
this code:
if (kill(pid, SIGKILL) < 0)
msg_fatal("%s: kill myself: %m", myname);
With this code:
exit(0);
And see if that fixes the PID=1 behavior?
Wietse