1 /*
2 * Copyright (c) 2005, 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.
8 *
9 * This code is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * version 2 for more details (a copy is included in the LICENSE file that
13 * accompanied this code).
14 *
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 *
466 if (ret == -1) {
467 log_debug(attach)("Failed to remove stale attach pid file at %s", fn);
468 }
469 }
470 }
471
472 int AttachListener::pd_init() {
473 JavaThread* thread = JavaThread::current();
474 ThreadBlockInVM tbivm(thread);
475
476 thread->set_suspend_equivalent();
477 // cleared by handle_special_suspend_equivalent_condition() or
478 // java_suspend_self() via check_and_wait_while_suspended()
479
480 int ret_code = BsdAttachListener::init();
481
482 // were we externally suspended while we were waiting?
483 thread->check_and_wait_while_suspended();
484
485 return ret_code;
486 }
487
488 // Attach Listener is started lazily except in the case when
489 // +ReduseSignalUsage is used
490 bool AttachListener::init_at_startup() {
491 if (ReduceSignalUsage) {
492 return true;
493 } else {
494 return false;
495 }
496 }
497
498 // If the file .attach_pid<pid> exists in the working directory
499 // or /tmp then this is the trigger to start the attach mechanism
500 bool AttachListener::is_init_trigger() {
501 if (init_at_startup() || is_initialized()) {
502 return false; // initialized at startup or already initialized
503 }
504 char fn[PATH_MAX + 1];
505 int ret;
|
1 /*
2 * Copyright (c) 2005, 2019, 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.
8 *
9 * This code is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * version 2 for more details (a copy is included in the LICENSE file that
13 * accompanied this code).
14 *
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 *
466 if (ret == -1) {
467 log_debug(attach)("Failed to remove stale attach pid file at %s", fn);
468 }
469 }
470 }
471
472 int AttachListener::pd_init() {
473 JavaThread* thread = JavaThread::current();
474 ThreadBlockInVM tbivm(thread);
475
476 thread->set_suspend_equivalent();
477 // cleared by handle_special_suspend_equivalent_condition() or
478 // java_suspend_self() via check_and_wait_while_suspended()
479
480 int ret_code = BsdAttachListener::init();
481
482 // were we externally suspended while we were waiting?
483 thread->check_and_wait_while_suspended();
484
485 return ret_code;
486 }
487
488 // TODO: Should be implemented if need.
489 // See src/hotspot/os/linux/attachListener_linux.cpp
490 bool AttachListener::check_socket_file() {
491 return false;
492 }
493
494 // Attach Listener is started lazily except in the case when
495 // +ReduseSignalUsage is used
496 bool AttachListener::init_at_startup() {
497 if (ReduceSignalUsage) {
498 return true;
499 } else {
500 return false;
501 }
502 }
503
504 // If the file .attach_pid<pid> exists in the working directory
505 // or /tmp then this is the trigger to start the attach mechanism
506 bool AttachListener::is_init_trigger() {
507 if (init_at_startup() || is_initialized()) {
508 return false; // initialized at startup or already initialized
509 }
510 char fn[PATH_MAX + 1];
511 int ret;
|