starter: Close open file descriptors after forking.

This avoids problems with Android's adb which leaves several file
descriptors open when executing processes.
This commit is contained in:
Tobias Brunner
2011-10-13 11:19:17 +02:00
parent 9a8fdc159a
commit 652ddf5ce2
+5 -1
View File
@@ -429,8 +429,11 @@ int main (int argc, char **argv)
{
case 0:
{
int fnull = open("/dev/null", O_RDWR);
int fnull;
closefrom(3);
fnull = open("/dev/null", O_RDWR);
if (fnull >= 0)
{
dup2(fnull, STDIN_FILENO);
@@ -438,6 +441,7 @@ int main (int argc, char **argv)
dup2(fnull, STDERR_FILENO);
close(fnull);
}
setsid();
}
break;