fcntl corrections

Peter Naulls peter at chocky.org
Sun Feb 9 04:57:06 PST 2003


This fixes behaviour in fcntl.c.  Additionally, is there any reason
to retain the __UNIXLIB_NO_COMMON_DEV stuff in dev.c?   I think it
should be removed for clarity, as it's clearly not in use.



Index: unixlib/source/unix/fcntl.c
===================================================================
RCS file: /usr/local/cvsroot/gccsdk/unixlib/source/unix/fcntl.c,v
retrieving revision 1.2.2.4
diff -u -r1.2.2.4 fcntl.c
--- unixlib/source/unix/fcntl.c	5 Aug 2002 09:04:18 -0000	1.2.2.4
+++ unixlib/source/unix/fcntl.c	9 Feb 2003 12:55:35 -0000
@@ -17,7 +17,7 @@
 #include <stdlib.h>
 #include <stdarg.h>
 #include <unistd.h>
-#include <sys/netdb.h>
+#include <netdb.h>
 #include <unixlib/unix.h>
 #include <unixlib/fd.h>
 #include <unixlib/dev.h>
@@ -64,13 +64,21 @@
       }
 
     case F_GETFD:
-      return file_desc->dflag;
+      return (file_desc->fflag & O_EXECCL) ? 1 : 0;
 
     case F_SETFD:
-      va_start (ap, cmd);
-      file_desc->dflag = va_arg (ap, int);
-      va_end (ap);
-      return 0;
+      {
+        /* Set close-on-exec flag */
+        va_start (ap, cmd);
+
+        if (va_arg (ap, int)) 
+          file_desc->fflag |= O_EXECCL;
+        else
+          file_desc->fflag &= ~O_EXECCL;
+
+        va_end (ap);
+        return 0;
+      }
 
     case F_GETFL:
       return file_desc->fflag;
@@ -108,17 +116,24 @@
 
     case F_SETUNL:
       {
-	int arg;
-
 	va_start (ap, cmd);
-	arg = va_arg (ap, int);
-	va_end (ap);
 
-	if (arg)
+	if (va_arg (ap, int))
 	  file_desc->fflag |= O_UNLINKED;
 	else
 	  file_desc->fflag &= ~O_UNLINKED;
+
+	va_end (ap);
+
 	return 0;
+      }
+
+    case F_SETOWN:
+      {
+        /* Set the process ID or process group that will receive SIGIO and
+           SIGURG  signals  for  events  on  file  descriptor fd. */
+        /* Don't do anything for now, just accept it. */
+        return 0;
       }
     }
 

-- 
------------------------------------------------------------------------
 Peter Naulls - peter at chocky.org
 Homepage                     -  http://www.chocky.org/
 RISC OS C Programming        -  http://www.riscos.info/
 Unix Programs on RISC OS     -  http://www.chocky.org/unix/
------------------------------------------------------------------------
 



More information about the gcc mailing list