OS code 11 (on linux) is "Resource temporarily unavailable". Could it be that you or the web server are setting up resource limits? Signal 11 (in case it should mean a signal code) is SIGSEGV which could possibly also be because of a too small stack or similar.
(Other things coming to mind: try to use \r\n or \015\012 instead of \n; does it find the shared libraries, are you using LD_LIBRARY_PATH as normal user but not under the webserver or similar?)
Christian.