https://bz.apache.org/SpamAssassin/show_bug.cgi?id=8007
Bug ID: 8007
Summary: POSIX::_exit of forked child in Win32 terminates
parent process
Product: Spamassassin
Version: unspecified
Hardware: PC
OS: Windows
Status: NEW
Severity: normal
Priority: P2
Component: Libraries
Assignee: [email protected]
Reporter: [email protected]
Target Milestone: Undefined
Created attachment 5788
--> https://bz.apache.org/SpamAssassin/attachment.cgi?id=5788&action=edit
perl script that demonstrates the different behavior between Windows and
Linux/Unix/macOS
There are three uses of POSIX::_exit() in our code right now, and they have an
unexpected side-effect when running on Windows of causing the parent process to
terminate.
>From perldoc perlfork:
"On some platforms such as Windows where the fork() system call is not
available, Perl can be built to emulate fork() at the interpreter level. While
the emulation is designed to be as compatible as possible with the real fork()
at the level of the Perl program, there are certain important differences that
stem from the fact that all the pseudo child "processes" created this way live
in the same real process as far as the operating system is concerned."
"exit() always exits just the executing pseudo-process, after automatically
wait()-ing for any outstanding child pseudo-processes. Note that this means
that the process as a whole will not exit unless all running pseudo-processes
have exited. See below for some limitations with open filehandles."
>From perldoc POSIX:
"_exit
This is identical to the C function _exit(). It exits the program immediately
which means among other things buffered I/O is not flushed."
Since on Windows a forked child is not in a new process, only a pseudo-process,
and unlike exit(), _exit() does not deal with the pseudo-process, terminating
the entire current process, a call to _exit() in a forked child under Windows
will terminate the parent too.
Currently there are three places that _exit() is used. 1) in spamd, to fix bug
4370 where it is a workaround for some unexpected problems; 2,3) In pyzor and
razor2 plugins where they are only used with the option to fork child
processes.
The effect of the use of _exit in spamd would be to cause spamd to terminate if
the unexpected problem with a child process is caught. If that was changed to
call exit() instead when in Windows, that should be fine with the worst case
scenario being that Windows could have occasional hung child spamd processes.
Razor2 and Pyzor plugins currently do not run under Windows, but Pyzor used to
and I'm making progress on getting it working again. The fix is to call exit()
when running on Windows.
I'll attach a small test script that demonstrates the different behavior on
Windows and elsewhere.
--
You are receiving this mail because:
You are the assignee for the bug.