src/solaris/native/java/lang/childproc.c

Print this page
rev 8725 : 8024854: Basic changes and files to build the class library on AIX
Contributed-by: luchsh@linux.vnet.ibm.com, spoole@linux.vnet.ibm.com, thomas.stuefe@sap.com
Reviewed-by: alanb, prr, sla, chegar, michaelm, mullan

@@ -64,10 +64,13 @@
 
 #ifdef _ALLBSD_SOURCE
 #define FD_DIR "/dev/fd"
 #define dirent64 dirent
 #define readdir64 readdir
+#elif defined(_AIX)
+/* AIX does not understand '/proc/self' - it requires the real process ID */
+#define FD_DIR aix_fd_dir
 #else
 #define FD_DIR "/proc/self/fd"
 #endif
 
 int

@@ -85,10 +88,16 @@
      * close a couple explicitly.  */
 
     close(from_fd);          /* for possible use by opendir() */
     close(from_fd + 1);      /* another one for good luck */
 
+#if defined(_AIX)
+    /* AIX does not understand '/proc/self' - it requires the real process ID */
+    char aix_fd_dir[32];     /* the pid has at most 19 digits */
+    snprintf(aix_fd_dir, 32, "/proc/%d/fd", getpid());
+#endif
+
     if ((dp = opendir(FD_DIR)) == NULL)
         return 0;
 
     /* We use readdir64 instead of readdir to work around Solaris bug
      * 6395699: /proc/self/fd fails to report file descriptors >= 1024 on Solaris 9