diff -r 889dae20c4c4 -r feea57b38a1c src/hotspot/os/posix/os_posix.cpp --- a/src/hotspot/os/posix/os_posix.cpp Thu Mar 07 16:15:43 2019 +0100 +++ b/src/hotspot/os/posix/os_posix.cpp Fri Mar 08 11:23:30 2019 +0100 @@ -31,6 +31,7 @@ #include "runtime/interfaceSupport.inline.hpp" #include "services/memTracker.hpp" #include "utilities/align.hpp" +#include "utilities/events.hpp" #include "utilities/formatBuffer.hpp" #include "utilities/macros.hpp" #include "utilities/vmError.hpp" @@ -1269,6 +1270,15 @@ return true; } +bool os::signal_sent_by_kill(const void* siginfo) { + const siginfo_t* const si = (const siginfo_t*)siginfo; + return si->si_code == SI_USER || si->si_code == SI_QUEUE +#ifdef SI_TKILL + || si->si_code == SI_TKILL +#endif + ; +} + void os::print_siginfo(outputStream* os, const void* si0) { const siginfo_t* const si = (const siginfo_t*) si0; @@ -1299,7 +1309,7 @@ // so it depends on the context which member to use. For synchronous error signals, // we print si_addr, unless the signal was sent by another process or thread, in // which case we print out pid or tid of the sender. - if (si->si_code == SI_USER || si->si_code == SI_QUEUE) { + if (signal_sent_by_kill(si)) { const pid_t pid = si->si_pid; os->print(", si_pid: %ld", (long) pid); if (IS_VALID_PID(pid)) { @@ -1325,6 +1335,25 @@ } +bool os::signal_thread(Thread* thread, int sig, const char* reason) { + OSThread* osthread = thread->osthread(); + if (osthread) { +#if defined (SOLARIS) + // Note: we cannot use pthread_kill on Solaris - not because + // its missing, but because we do not have the pthread_t id. + int status = thr_kill(osthread->thread_id(), sig); +#else + int status = pthread_kill(osthread->pthread_id(), sig); +#endif + if (status == 0) { + Events::log(Thread::current(), "sent signal %d to Thread " INTPTR_FORMAT " because %s.", + sig, p2i(thread), reason); + return true; + } + } + return false; +} + int os::Posix::unblock_thread_signal_mask(const sigset_t *set) { return pthread_sigmask(SIG_UNBLOCK, set, NULL); }