< prev index next >

src/jdk.attach/solaris/native/libattach/VirtualMachineImpl.c

Print this page
rev 12879 : 8136556: Add the ability to perform static builds of MacOSX x64 binaries
Reviewed-by: ihse, bdelsart, gadams, lfoltan, rriggs, hseigel, twisti
   1 /*
   2  * Copyright (c) 2005, 2014, 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


  27 #include <door.h>
  28 #include <stdlib.h>
  29 #include <unistd.h>
  30 #include <signal.h>
  31 #include <string.h>
  32 #include <fcntl.h>
  33 #include <errno.h>
  34 #include <limits.h>
  35 
  36 #include "jni.h"
  37 #include "jni_util.h"
  38 #include "jvm.h"
  39 
  40 #include "sun_tools_attach_VirtualMachineImpl.h"
  41 
  42 #define RESTARTABLE(_cmd, _result) do { \
  43   do { \
  44     _result = _cmd; \
  45   } while((_result == -1) && (errno == EINTR)); \
  46 } while(0)





  47 
  48 /*
  49  * Class:     sun_tools_attach_VirtualMachineImpl
  50  * Method:    open
  51  * Signature: (Ljava/lang/String;)I
  52  */
  53 JNIEXPORT jint JNICALL Java_sun_tools_attach_VirtualMachineImpl_open
  54   (JNIEnv *env, jclass cls, jstring path)
  55 {
  56     jboolean isCopy;
  57     const char* p = GetStringPlatformChars(env, path, &isCopy);
  58     if (p == NULL) {
  59         return 0;
  60     } else {
  61         int fd;
  62         int err = 0;
  63 
  64         fd = open(p, O_RDWR);
  65         if (fd == -1) {
  66             err = errno;


   1 /*
   2  * Copyright (c) 2005, 2015, 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


  27 #include <door.h>
  28 #include <stdlib.h>
  29 #include <unistd.h>
  30 #include <signal.h>
  31 #include <string.h>
  32 #include <fcntl.h>
  33 #include <errno.h>
  34 #include <limits.h>
  35 
  36 #include "jni.h"
  37 #include "jni_util.h"
  38 #include "jvm.h"
  39 
  40 #include "sun_tools_attach_VirtualMachineImpl.h"
  41 
  42 #define RESTARTABLE(_cmd, _result) do { \
  43   do { \
  44     _result = _cmd; \
  45   } while((_result == -1) && (errno == EINTR)); \
  46 } while(0)
  47 
  48 /*
  49  * Declare library specific JNI_Onload entry if static build
  50  */
  51 DEF_STATIC_JNI_OnLoad
  52 
  53 /*
  54  * Class:     sun_tools_attach_VirtualMachineImpl
  55  * Method:    open
  56  * Signature: (Ljava/lang/String;)I
  57  */
  58 JNIEXPORT jint JNICALL Java_sun_tools_attach_VirtualMachineImpl_open
  59   (JNIEnv *env, jclass cls, jstring path)
  60 {
  61     jboolean isCopy;
  62     const char* p = GetStringPlatformChars(env, path, &isCopy);
  63     if (p == NULL) {
  64         return 0;
  65     } else {
  66         int fd;
  67         int err = 0;
  68 
  69         fd = open(p, O_RDWR);
  70         if (fd == -1) {
  71             err = errno;


< prev index next >