< prev index next >

src/java.base/unix/native/libjava/ProcessHandleImpl_unix.c

Print this page


   1 /*
   2  * Copyright (c) 2014, 2017, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.  Oracle designates this
   8  * particular file as subject to the "Classpath" exception as provided
   9  * by Oracle in the LICENSE file that accompanied this code.
  10  *
  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any


  41 #include <dirent.h>
  42 #include <ctype.h>
  43 #include <limits.h>
  44 #include <sys/types.h>
  45 #include <sys/stat.h>
  46 #include <sys/wait.h>
  47 
  48 /* For POSIX-compliant getpwuid_r on Solaris */
  49 #if defined(__solaris__)
  50 #define _POSIX_PTHREAD_SEMANTICS
  51 #endif
  52 #include <pwd.h>
  53 
  54 #ifdef _AIX
  55 #include <sys/procfs.h>
  56 #endif
  57 #ifdef __solaris__
  58 #include <procfs.h>
  59 #endif
  60 






  61 /**
  62  * This file contains the implementation of the native ProcessHandleImpl
  63  * functions which are common to all Unix variants.
  64  *
  65  * The currently supported Unix variants are Solaris, Linux, MaxOS X and AIX.
  66  * The various similarities and differences between these systems make it hard
  67  * to find a clear boundary between platform specific and shared code.
  68  *
  69  * In order to ease code sharing between the platforms while still keeping the
  70  * code as clean as possible (i.e. free of preprocessor macros) we use the
  71  * following source code layout (remember that ProcessHandleImpl_unix.c will
  72  * be compiled on EVERY Unix platform while ProcessHandleImpl_<os>.c will be
  73  * only compiled on the specific OS):
  74  *
  75  * - all the JNI wrappers for the ProcessHandleImpl functions go into this file
  76  * - if their implementation is common on ALL the supported Unix platforms it
  77  *   goes right into the JNI wrappers
  78  * - if the whole function or substantial parts of it are platform dependent,
  79  *   the implementation goes into os_<function_name> functions in
  80  *   ProcessHandleImpl_<os>.c


   1 /*
   2  * Copyright (c) 2014, 2018, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.  Oracle designates this
   8  * particular file as subject to the "Classpath" exception as provided
   9  * by Oracle in the LICENSE file that accompanied this code.
  10  *
  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any


  41 #include <dirent.h>
  42 #include <ctype.h>
  43 #include <limits.h>
  44 #include <sys/types.h>
  45 #include <sys/stat.h>
  46 #include <sys/wait.h>
  47 
  48 /* For POSIX-compliant getpwuid_r on Solaris */
  49 #if defined(__solaris__)
  50 #define _POSIX_PTHREAD_SEMANTICS
  51 #endif
  52 #include <pwd.h>
  53 
  54 #ifdef _AIX
  55 #include <sys/procfs.h>
  56 #endif
  57 #ifdef __solaris__
  58 #include <procfs.h>
  59 #endif
  60 
  61 #if defined(_AIX)
  62   #define DIR DIR64
  63   #define opendir opendir64
  64   #define closedir closedir64
  65 #endif
  66 
  67 /**
  68  * This file contains the implementation of the native ProcessHandleImpl
  69  * functions which are common to all Unix variants.
  70  *
  71  * The currently supported Unix variants are Solaris, Linux, MaxOS X and AIX.
  72  * The various similarities and differences between these systems make it hard
  73  * to find a clear boundary between platform specific and shared code.
  74  *
  75  * In order to ease code sharing between the platforms while still keeping the
  76  * code as clean as possible (i.e. free of preprocessor macros) we use the
  77  * following source code layout (remember that ProcessHandleImpl_unix.c will
  78  * be compiled on EVERY Unix platform while ProcessHandleImpl_<os>.c will be
  79  * only compiled on the specific OS):
  80  *
  81  * - all the JNI wrappers for the ProcessHandleImpl functions go into this file
  82  * - if their implementation is common on ALL the supported Unix platforms it
  83  *   goes right into the JNI wrappers
  84  * - if the whole function or substantial parts of it are platform dependent,
  85  *   the implementation goes into os_<function_name> functions in
  86  *   ProcessHandleImpl_<os>.c


< prev index next >