< prev index next >

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

Print this page


   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


  32 #include <string.h>
  33 #include <errno.h>
  34 #include <unistd.h>
  35 #include <signal.h>
  36 #include <dirent.h>
  37 #include <ctype.h>
  38 #include <sys/types.h>
  39 #include <sys/socket.h>
  40 #include <sys/stat.h>
  41 #include <sys/syslimits.h>
  42 #include <sys/un.h>
  43 #include <fcntl.h>
  44 
  45 #include "sun_tools_attach_VirtualMachineImpl.h"
  46 
  47 #define RESTARTABLE(_cmd, _result) do { \
  48   do { \
  49     _result = _cmd; \
  50   } while((_result == -1) && (errno == EINTR)); \
  51 } while(0)





  52 
  53 /*
  54  * Class:     sun_tools_attach_VirtualMachineImpl
  55  * Method:    socket
  56  * Signature: ()I
  57  */
  58 JNIEXPORT jint JNICALL Java_sun_tools_attach_VirtualMachineImpl_socket
  59   (JNIEnv *env, jclass cls)
  60 {
  61     int fd = socket(PF_UNIX, SOCK_STREAM, 0);
  62     if (fd == -1) {
  63         JNU_ThrowIOExceptionWithLastError(env, "socket");
  64     }
  65     return (jint)fd;
  66 }
  67 
  68 /*
  69  * Class:     sun_tools_attach_VirtualMachineImpl
  70  * Method:    connect
  71  * Signature: (ILjava/lang/String;)I


   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


  32 #include <string.h>
  33 #include <errno.h>
  34 #include <unistd.h>
  35 #include <signal.h>
  36 #include <dirent.h>
  37 #include <ctype.h>
  38 #include <sys/types.h>
  39 #include <sys/socket.h>
  40 #include <sys/stat.h>
  41 #include <sys/syslimits.h>
  42 #include <sys/un.h>
  43 #include <fcntl.h>
  44 
  45 #include "sun_tools_attach_VirtualMachineImpl.h"
  46 
  47 #define RESTARTABLE(_cmd, _result) do { \
  48   do { \
  49     _result = _cmd; \
  50   } while((_result == -1) && (errno == EINTR)); \
  51 } while(0)
  52 
  53 /*
  54  * Declare library specific JNI_Onload entry if static build
  55  */
  56 DEF_STATIC_JNI_OnLoad
  57 
  58 /*
  59  * Class:     sun_tools_attach_VirtualMachineImpl
  60  * Method:    socket
  61  * Signature: ()I
  62  */
  63 JNIEXPORT jint JNICALL Java_sun_tools_attach_VirtualMachineImpl_socket
  64   (JNIEnv *env, jclass cls)
  65 {
  66     int fd = socket(PF_UNIX, SOCK_STREAM, 0);
  67     if (fd == -1) {
  68         JNU_ThrowIOExceptionWithLastError(env, "socket");
  69     }
  70     return (jint)fd;
  71 }
  72 
  73 /*
  74  * Class:     sun_tools_attach_VirtualMachineImpl
  75  * Method:    connect
  76  * Signature: (ILjava/lang/String;)I


< prev index next >