aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTobias Brunner <tobias@strongswan.org>2011-10-13 10:35:41 +0200
committerTobias Brunner <tobias@strongswan.org>2011-10-13 11:19:17 +0200
commit652ddf5ce2fad08f6569096dd56a821500cc5ba4 (patch)
treeaa0d1e9a7d19aa6a713059a29c085dd05d90702b
parent9a8fdc159a49ba82568f53cb9275b3ded092ba76 (diff)
downloadstrongswan-652ddf5ce2fad08f6569096dd56a821500cc5ba4.tar.bz2
strongswan-652ddf5ce2fad08f6569096dd56a821500cc5ba4.tar.xz
starter: Close open file descriptors after forking.
This avoids problems with Android's adb which leaves several file descriptors open when executing processes.
-rw-r--r--src/starter/starter.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/src/starter/starter.c b/src/starter/starter.c
index 659122a7a..b1a9a159a 100644
--- a/src/starter/starter.c
+++ b/src/starter/starter.c
@@ -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;