]> git.sven.stormbind.net Git - sven/jattach.git/blobdiff - src/posix/jattach.c
New upstream version 2.2
[sven/jattach.git] / src / posix / jattach.c
index 53d9dfba127d352752eef713affd7710af7db30e..a8a851e11d5d5298239f2c1378bba8275fa4acf8 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * 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;
@@ -42,7 +44,7 @@ int jattach(int pid, int argc, char** argv) {
     // 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.
@@ -58,9 +60,9 @@ int jattach(int pid, int argc, char** argv) {
     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);
     }
 }
 
@@ -69,7 +71,6 @@ int jattach(int pid, int argc, char** argv) {
 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"
@@ -86,7 +87,7 @@ int main(int argc, char** argv) {
         return 1;
     }
 
-    return jattach(pid, argc - 2, argv + 2);
+    return jattach(pid, argc - 2, argv + 2, 1);
 }
 
 #endif // JATTACH_VERSION