src/os/linux/vm/attachListener_linux.cpp
Index Unified diffs Context diffs Sdiffs Wdiffs Patch New Old Previous File Next File hotspot.open Sdiff src/os/linux/vm

src/os/linux/vm/attachListener_linux.cpp

Print this page




 159       }
 160       if (LinuxAttachListener::has_path()) {
 161         ::unlink(LinuxAttachListener::path());
 162       }
 163     }
 164   }
 165 }
 166 
 167 // Initialization - create a listener socket and bind it to a file
 168 
 169 int LinuxAttachListener::init() {
 170   char path[UNIX_PATH_MAX];          // socket file
 171   char initial_path[UNIX_PATH_MAX];  // socket file during setup
 172   int listener;                      // listener socket (file descriptor)
 173 
 174   // register function to cleanup
 175   ::atexit(listener_cleanup);
 176 
 177   int n = snprintf(path, UNIX_PATH_MAX, "%s/.java_pid%d",
 178                    os::get_temp_directory(), os::current_process_id());
 179   if (n <= (int)UNIX_PATH_MAX) {
 180     n = snprintf(initial_path, UNIX_PATH_MAX, "%s.tmp", path);
 181   }
 182   if (n > (int)UNIX_PATH_MAX) {
 183     return -1;
 184   }
 185 
 186   // create the listener socket
 187   listener = ::socket(PF_UNIX, SOCK_STREAM, 0);
 188   if (listener == -1) {
 189     return -1;
 190   }
 191 
 192   // bind socket
 193   struct sockaddr_un addr;
 194   addr.sun_family = AF_UNIX;
 195   strcpy(addr.sun_path, initial_path);
 196   ::unlink(initial_path);
 197   int res = ::bind(listener, (struct sockaddr*)&addr, sizeof(addr));
 198   if (res == -1) {
 199     RESTARTABLE(::close(listener), res);
 200     return -1;
 201   }
 202 




 159       }
 160       if (LinuxAttachListener::has_path()) {
 161         ::unlink(LinuxAttachListener::path());
 162       }
 163     }
 164   }
 165 }
 166 
 167 // Initialization - create a listener socket and bind it to a file
 168 
 169 int LinuxAttachListener::init() {
 170   char path[UNIX_PATH_MAX];          // socket file
 171   char initial_path[UNIX_PATH_MAX];  // socket file during setup
 172   int listener;                      // listener socket (file descriptor)
 173 
 174   // register function to cleanup
 175   ::atexit(listener_cleanup);
 176 
 177   int n = snprintf(path, UNIX_PATH_MAX, "%s/.java_pid%d",
 178                    os::get_temp_directory(), os::current_process_id());
 179   if (n < (int)UNIX_PATH_MAX) {
 180     n = snprintf(initial_path, UNIX_PATH_MAX, "%s.tmp", path);
 181   }
 182   if (n >= (int)UNIX_PATH_MAX) {
 183     return -1;
 184   }
 185 
 186   // create the listener socket
 187   listener = ::socket(PF_UNIX, SOCK_STREAM, 0);
 188   if (listener == -1) {
 189     return -1;
 190   }
 191 
 192   // bind socket
 193   struct sockaddr_un addr;
 194   addr.sun_family = AF_UNIX;
 195   strcpy(addr.sun_path, initial_path);
 196   ::unlink(initial_path);
 197   int res = ::bind(listener, (struct sockaddr*)&addr, sizeof(addr));
 198   if (res == -1) {
 199     RESTARTABLE(::close(listener), res);
 200     return -1;
 201   }
 202 


src/os/linux/vm/attachListener_linux.cpp
Index Unified diffs Context diffs Sdiffs Wdiffs Patch New Old Previous File Next File