adns-ocloexec
authorAnas Nashif <anas.nashif@intel.com>
Wed, 7 Nov 2012 17:28:16 +0000 (09:28 -0800)
committerAnas Nashif <anas.nashif@intel.com>
Wed, 7 Nov 2012 17:28:16 +0000 (09:28 -0800)
src/event.c
src/setup.c

index ad5861e..b30377e 100644 (file)
@@ -123,7 +123,7 @@ void adns__tcp_tryconnect(adns_state ads, struct timeval now) {
       adns__diag(ads,-1,0,"unable to find protocol no. for TCP !");
       return;
     }
-    fd= socket(AF_INET,SOCK_STREAM,proto->p_proto);
+    fd= socket(AF_INET,SOCK_STREAM|SOCK_CLOEXEC,proto->p_proto);
     if (fd<0) {
       adns__diag(ads,-1,0,"cannot create TCP socket: %s",strerror(errno));
       return;
index 57037cc..18b53be 100644 (file)
@@ -464,7 +464,7 @@ static const char *instrum_getenv(adns_state ads, const char *envvar) {
 static void readconfig(adns_state ads, const char *filename, int warnmissing) {
   getline_ctx gl_ctx;
   
-  gl_ctx.file= fopen(filename,"r");
+  gl_ctx.file= fopen(filename,"re");
   if (!gl_ctx.file) {
     if (errno == ENOENT) {
       if (warnmissing)
@@ -572,7 +572,7 @@ static int init_finish(adns_state ads) {
   }
 
   proto= getprotobyname("udp"); if (!proto) { r= ENOPROTOOPT; goto x_free; }
-  ads->udpsocket= socket(AF_INET,SOCK_DGRAM,proto->p_proto);
+  ads->udpsocket= socket(AF_INET,SOCK_DGRAM|SOCK_CLOEXEC,proto->p_proto);
   if (ads->udpsocket<0) { r= errno; goto x_free; }
 
   r= adns__setnonblock(ads,ads->udpsocket);