“Resource temporarily unavailable” error from exim running under cygwin

cygwinexim

I have recently setup exim version 4.86.1 running as a Cygwin service in Windows Server 2008 R2. If I send a single email at a time, it works fine. However, if I try and send 10 emails, each immediately after the other using a script, maybe only one or two emails will work. Adding a 5 second pause between emails also works.

In the exim_panic.log file, each failure is due to the following type of error:

2016-06-07 04:09:00 O8DPZ0-000708-7G Cannot lock /var/spool/exim/input/0/O8DPZ0-000708-7G-D (11): Resource temporarily unavailable

Meanwhile, the /var/spool/exim/input directory contains a bunch of zero sized files with names matching that in the error message above (i.e., O8DPZ0-000708-7G-D). These messages are not in the queue, since exim -bpc returns zero, and exim isn't retrying to send the emails.

Best Answer

The Resource temporarily unavailable error typically means you’ve hit a system or process resource limit such as available memory, the number of allowed user processes, the number of files a user can have open at any one time. You can get this error when starting a new process, opening a new file or when a currently running process asks the kernel for more memory.

Some of these limits are user limits which can be set using the ulimit command. Running the ulimit -a command will show what user limits are currently set to, e.g.,

$ ulimit -a

core file size          (blocks, -c) unlimited
data seg size           (kbytes, -d) unlimited
file size               (blocks, -f) unlimited
open files                      (-n) 256
pipe size            (512 bytes, -p) 8
stack size              (kbytes, -s) 2036
cpu time               (seconds, -t) unlimited
max user processes              (-u) 256
virtual memory          (kbytes, -v) unlimited

From the error message it sounds like that your problem might be due to running out of file descriptors. It might be worth checking what file descriptors are open by running

ls -l /proc/<PID>/fd

Cygwin specific

Similar problems can also be caused by one of the Big List Of Dodgy Apps (a list of applications that interfere with the normal working of Cygwin by intrusively injecting themselves in the system call chain).

I’ve never used Exim so I don’t know if it forks many child processes while it’s operating but Fork failures may also be an issue; they are documented in the Cygwin FAQ: How do I fix fork() failures?. Sometimes installed libraries are not updated properly and they have to be updated using the Cygwin setup.exe, or by running rebaseall. See

Finally, I used to receive a lot of Resource temporarily unavailable messages when I was running 32-bit Cygwin. After upgrading to 64-bit, these mostly went away.