hotspot/src/os/bsd/vm/attachListener_bsd.cpp
changeset 18931 5de3638104b4
parent 18078 10417cf9967d
child 19269 59693d90fd61
equal deleted inserted replaced
18928:ac0163dd0a50 18931:5de3638104b4
     1 /*
     1 /*
     2  * Copyright (c) 2005, 2012, Oracle and/or its affiliates. All rights reserved.
     2  * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     4  *
     4  *
     5  * This code is free software; you can redistribute it and/or modify it
     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
     6  * under the terms of the GNU General Public License version 2 only, as
     7  * published by the Free Software Foundation.
     7  * published by the Free Software Foundation.
   435   thread->check_and_wait_while_suspended();
   435   thread->check_and_wait_while_suspended();
   436 
   436 
   437   return op;
   437   return op;
   438 }
   438 }
   439 
   439 
       
   440 
       
   441 // Performs initialization at vm startup
       
   442 // For BSD we remove any stale .java_pid file which could cause
       
   443 // an attaching process to think we are ready to receive on the
       
   444 // domain socket before we are properly initialized
       
   445 
       
   446 void AttachListener::vm_start() {
       
   447   char fn[UNIX_PATH_MAX];
       
   448   struct stat64 st;
       
   449   int ret;
       
   450 
       
   451   int n = snprintf(fn, UNIX_PATH_MAX, "%s/.java_pid%d",
       
   452            os::get_temp_directory(), os::current_process_id());
       
   453   assert(n < (int)UNIX_PATH_MAX, "java_pid file name buffer overflow");
       
   454 
       
   455   RESTARTABLE(::stat64(fn, &st), ret);
       
   456   if (ret == 0) {
       
   457     ret = ::unlink(fn);
       
   458     if (ret == -1) {
       
   459       debug_only(warning("failed to remove stale attach pid file at %s", fn));
       
   460     }
       
   461   }
       
   462 }
       
   463 
   440 int AttachListener::pd_init() {
   464 int AttachListener::pd_init() {
   441   JavaThread* thread = JavaThread::current();
   465   JavaThread* thread = JavaThread::current();
   442   ThreadBlockInVM tbivm(thread);
   466   ThreadBlockInVM tbivm(thread);
   443 
   467 
   444   thread->set_suspend_equivalent();
   468   thread->set_suspend_equivalent();