Debugging Postfix
September 28, 2008 Compile Postfix
Using strace to Find Problems
The strace command allows you to view the activities of a process. The first thing you will need to do is locate the process ID that you want to trace.
ps aux | grep postfix
Here is partiial output of what this command will provide:
root 5049 0.0 0.6 5396 1736 ? Ss 06:25 0:00 /usr/lib/postfix/master
postfix 5050 0.0 0.6 5404 1652 ? S 06:25 0:00 pickup -l -t fifo -u -c
postfix 5052 0.0 0.7 5444 1832 ? S 06:25 0:00 qmgr -l -t fifo -u
postfix 5065 0.0 0.9 5772 2460 ? S 06:30 0:00 tlsmgr -l -t unix -u -c
postfix 5092 0.0 0.9 5544 2316 ? S 06:40 0:00 smtp -t unix -u -c
Now you can select a process ID, like 5050 and use strace on that PID.
Now as root, use strace.
strace -p 5050
Process 5050 attached – interrupt to quit
alarm(333) = 274
time(NULL) = 1222519411
epoll_wait(8, {{EPOLLIN, {u32=6, u64=577892986457686022}}}, 100, 41000) = 1
time(NULL) = 1222519412
write(5, “\272\23\0\0\1\0\0\0\0\0\0\0″, 12) = 12
read(6, “W”, 1024) = 1
open(“maildrop”, O_RDONLY|O_NONBLOCK|O_LARGEFILE|O_DIRECTORY|0×80000) = 9
fstat64(9, {st_mode=S_IFDIR|S_ISVTX|0730, st_size=4096, …}) = 0
getdents64(9, /* 2 entries */, 4096) = 48
getdents64(9, /* 0 entries */, 4096) = 0
close(9) = 0
write(5, “\272\23\0\0\1\0\0\0\1\0\0\0″, 12) = 12
time(NULL) = 1222519412
alarm(333) = 332
time(NULL) = 1222519412
Running a Debugger for Postfix
If you are having continual problems with Postfix you can runs the gdb debugger which does not require a graphical interface. This is a non-interactive debugger that will print a stack trace if the process crashes. Edit the main.cf file and add this information.
debugger_command =
PATH=/bin:/usr/bin:/usr/local/bin; export PATH; (echo cont; echo
where; sleep 8640000) | gdb $daemon_directory/$process_name
$process_id 2>&1
>$config_directory/$process_name.$process_id.log & sleep 5
Now edit the master.cf and add the “-D” at the end of the line. This will run each daemon under the control of the debugger as described in your main.cf file.
smtp inet n - - - - smtpd -D
Save and restart Postfix. Now when the process is started an output file will be created and named after the daemon and the process ID. If the process crashes a stack trace will be written to the logfile.

