I've a very basic Linux script (**/home/scripts/script.sh**):

```
#!/bin/bash
echo 'a' | /bin/netcat -vv 10.10.10.1 3333
echo "done" > /tmp/result

```

When I try to run it from the shell, it works fine. So script is good (also, **done** is written into /tmp/result file):

```
# /home/scripts/script.sh
10.10.10.1: inverse host lookup failed: Unknown host
(UNKNOWN) [10.10.10.1] 3333 (?) open
AABBCCDDEEF
 sent 2, rcvd 13
#

```

However when I'm trying to run it from C++ code in a foreground daemon:

```
const char **argv = new const char* [3];
argv[0] = "/home/scripts/script.sh";
argv[1] = "/home/scripts/script.sh";
argv[2] = NULL;
execv(argv[0], const_cast<char**>(&argv[1]));

```

For a short time it works good (for 3-5mins).
After that short period the script running fails, nc's return code is 1, and this is the output:

```
10.10.10.1: inverse host lookup failed: Unknown host
(UNKNOWN) [10.10.10.1] 3333 (?) open
Preposterous fd value 17
 sent 0, rcvd 0

```

Why is that fd value is preposterous? My daemon opens some files during the first 3-5 min, maybe netcat is not able to deal with larger numbers as fd?

How shall I overcome on this issue?