/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
#include "jni.h"
#include "jni_util.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <errno.h>
#include <unistd.h>
#include <signal.h>
#include <dirent.h>
#include <ctype.h>
#include "sun_tools_attach_LinuxVirtualMachine.h"
do { \
} while(0)
/*
* Defines a callback that is invoked for each process
*/
/*
* Invokes the callback function for each process
*/
/*
* To locate the children we scan /proc looking for files that have a
* position integer as a filename.
*/
return;
}
continue;
}
/* skip files that aren't numbers */
if ((int)pid <= 0) {
continue;
}
/* invoke the callback */
}
}
/*
* Returns the parent pid of a given pid, or -1 if not found
*/
char state;
int statlen;
int i, p;
char* s;
/*
*/
return -1;
}
/*
* The format is: pid (command) state ppid ...
* As the command could be anything we must find the right most
* ")" and then skip the white spaces that follow it.
*/
if (s == NULL) {
return -1;
}
do s++; while (isspace(*s));
return (pid_t)p;
}
/*
* Class: sun_tools_attach_LinuxVirtualMachine
* Method: socket
* Signature: ()I
*/
{
if (fd == -1) {
}
}
/*
* Class: sun_tools_attach_LinuxVirtualMachine
* Method: connect
*/
{
if (p != NULL) {
int err = 0;
}
if (isCopy) {
}
/*
* If the connect failed then we throw the appropriate exception
* here (can't throw it before releasing the string as can't call
* JNI with pending exception)
*/
if (err != 0) {
} else {
}
}
}
}
}
/*
* Class: sun_tools_attach_LinuxVirtualMachine
* Method: isLinuxThreads
* Signature: ()V
*/
{
# ifndef _CS_GNU_LIBPTHREAD_VERSION
# endif
size_t n;
char* s;
if (n <= 0) {
/* glibc before 2.3.2 only has LinuxThreads */
return JNI_TRUE;
}
s = (char *)malloc(n);
if (s == NULL) {
return JNI_TRUE;
}
confstr(_CS_GNU_LIBPTHREAD_VERSION, s, n);
/*
* If the LIBPTHREAD version include "NPTL" then we know we
* have the new threads library and not LinuxThreads
*/
free(s);
return res;
}
/*
* Structure and callback function used to count the children of
* a given process, and record the pid of the "manager thread".
*/
typedef struct {
int count;
/*
* Remember the pid of the first child. If the final count is
* one then this is the pid of the LinuxThreads manager.
*/
}
}
}
/*
* Class: sun_tools_attach_LinuxVirtualMachine
* Method: getLinuxThreadsManager
* Signature: (I)I
*/
{
/*
* Iterate over all processes to find how many children 'pid' has
*/
/*
* If there's no children then this is likely the pid of the primordial
* created by the launcher - in that case the LinuxThreads manager is the
* parent of this process.
*/
if ((int)parent > 0) {
}
}
/*
* There's one child so this is likely the embedded VM case where the
* the primordial thread == LinuxThreads initial thread. The LinuxThreads
* manager in that case is the child.
*/
}
/*
* If we get here it's most likely we were given the wrong pid
*/
return -1;
}
/*
* Structure and callback function used to send a QUIT signal to all
* children of a given process
*/
typedef struct {
}
}
/*
* Class: sun_tools_attach_LinuxVirtualMachine
* Method: sendQuitToChildrenOf
* Signature: (I)V
*/
{
/*
* Iterate over all children of 'pid' and send a QUIT signal to each.
*/
}
/*
* Class: sun_tools_attach_LinuxVirtualMachine
* Method: sendQuitTo
* Signature: (I)V
*/
{
}
}
/*
* Class: sun_tools_attach_LinuxVirtualMachine
* Method: checkPermissions
*/
{
if (p != NULL) {
int res;
/*
*/
if (res != 0) {
/* save errno */
}
/* release p here before we throw an I/O exception */
if (isCopy) {
}
if (res == 0) {
}
} else {
}
}
}
}
/*
* Class: sun_tools_attach_LinuxVirtualMachine
* Method: close
* Signature: (I)V
*/
{
int res;
}
/*
* Class: sun_tools_attach_LinuxVirtualMachine
* Method: read
* Signature: (I[BI)I
*/
{
ssize_t n;
}
if (n == -1) {
} else {
if (n == 0) {
n = -1; // EOF
} else {
}
}
return n;
}
/*
* Class: sun_tools_attach_LinuxVirtualMachine
* Method: write
* Signature: (I[B)V
*/
{
do {
int n;
}
if (n > 0) {
off += n;
remaining -= n;
} else {
return;
}
} while (remaining > 0);
}