/*
- * Copyright 2021 Andrei Pangin
+ * Copyright jattach authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
extern int is_openj9_process(int pid);
-extern int jattach_openj9(int pid, int nspid, int argc, char** argv);
-extern int jattach_hotspot(int pid, int nspid, int argc, char** argv);
+extern int jattach_openj9(int pid, int nspid, int argc, char** argv, int print_output);
+extern int jattach_hotspot(int pid, int nspid, int argc, char** argv, int print_output);
+
+int mnt_changed = 0;
__attribute__((visibility("default")))
-int jattach(int pid, int argc, char** argv) {
+int jattach(int pid, int argc, char** argv, int print_output) {
uid_t my_uid = geteuid();
gid_t my_gid = getegid();
uid_t target_uid = my_uid;
// Network and IPC namespaces are essential for OpenJ9 connection.
enter_ns(pid, "net");
enter_ns(pid, "ipc");
- int mnt_changed = enter_ns(pid, "mnt");
+ mnt_changed = enter_ns(pid, "mnt");
// In HotSpot, dynamic attach is allowed only for the clients with the same euid/egid.
// If we are running under root, switch to the required euid/egid automatically.
signal(SIGPIPE, SIG_IGN);
if (is_openj9_process(nspid)) {
- return jattach_openj9(pid, nspid, argc, argv);
+ return jattach_openj9(pid, nspid, argc, argv, print_output);
} else {
- return jattach_hotspot(pid, nspid, argc, argv);
+ return jattach_hotspot(pid, nspid, argc, argv, print_output);
}
}
int main(int argc, char** argv) {
if (argc < 3) {
printf("jattach " JATTACH_VERSION " built on " __DATE__ "\n"
- "Copyright 2021 Andrei Pangin\n"
"\n"
"Usage: jattach <pid> <cmd> [args ...]\n"
"\n"
return 1;
}
- return jattach(pid, argc - 2, argv + 2);
+ return jattach(pid, argc - 2, argv + 2, 1);
}
#endif // JATTACH_VERSION