# Send() function failing kills the worker process

**URL:** <https://www.ruby-forum.com/t/send-function-failing-kills-the-worker-process/190679>\
**Category:** NGINX\
**Created:** [June 24, 2010, 11:47pm UTC](https://www.ruby-forum.com/t/send-function-failing-kills-the-worker-process/190679 "2010-06-24T23:47:55Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![cjt72](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/8e7dd6/32.png) [@cjt72](https://www.ruby-forum.com/u/cjt72)\
**Post date:** [June 24, 2010, 11:47pm UTC](https://www.ruby-forum.com/t/send-function-failing-kills-the-worker-process/190679/1 "2010-06-24T23:47:55Z")

</div>

Hi all,

I’m making an nginx module to communicate with my database.

I’m trying to use the C send() function in my handler, but it seems that  
whenever send() fails it kills the whole process as opposed to just  
returning a -1.

In the error log I get “error: network error”.

Is there anyway I can suppress this behavior?

nginx version: nginx/0.8.39  
built by gcc 4.2.1 (Apple Inc. build 5659)  
configure arguments: --add-module=…/nginx-gridfs --with-debug

nginx.conf:

user nobody;  
worker\_processes 1;

error\_log /usr/local/nginx/log debug;

events {  
worker\_connections 1024;  
}

http {  
include mime.types;  
default\_type application/octet-stream;

```
sendfile on;

keepalive_timeout 65;

gzip on;

server {
    listen 80;
    server_name localhost;

    location / {
        root html;
        index index.html index.htm;
    }

    error_page 404 /404.html;

    error_page 500 502 503 504 /50x.html;
    location = /50x.html {
        root html;
    }

    location /gridfs/_id/ {
        gridfs_db test;
    }
}

```

}

Posted at Nginx Forum:

> **[send() function failing kills the worker process](https://forum.nginx.org/read.php?2,102050,102050#msg-102050)**
>
> Hi all, I'm making an nginx module to communicate with my database. I'm trying to use the C send() function in my handler, but it seems that whenever send() fails it kills the whole process as opposed to just returning a -1. In the error log I get...

---

<div class="post-metadata">

**Author:** ![cjt72](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/8e7dd6/32.png) [@cjt72](https://www.ruby-forum.com/u/cjt72)\
**Post date:** [June 25, 2010, 1:50pm UTC](https://www.ruby-forum.com/t/send-function-failing-kills-the-worker-process/190679/2 "2010-06-25T13:50:22Z")

</div>

Hello!

On Thu, Jun 24, 2010 at 05:46:31PM -0400, cjt72 wrote:

> I’m making an nginx module to communicate with my database.
> 
> I’m trying to use the C send() function in my handler, but it seems that  
> whenever send() fails it kills the whole process as opposed to just  
> returning a -1.
> 
> In the error log I get “error: network error”.
> 
> Is there anyway I can suppress this behavior?

Calling C function send() never results in exit() on error, most  
likely you call it somewhere yourself, either directly or via  
something like BSD’s err() wrapper. Try posting your code if in  
doubt.

Maxim D.
