X-Git-Url: https://git.sven.stormbind.net/?p=sven%2Fjattach.git;a=blobdiff_plain;f=src%2Fposix%2Fjattach.c;fp=src%2Fposix%2Fjattach.c;h=a8a851e11d5d5298239f2c1378bba8275fa4acf8;hp=53d9dfba127d352752eef713affd7710af7db30e;hb=443b80898c49b466100dffc328ea8905887af2a1;hpb=98ce3928a99273b631c525a81df022e6f8ec46a7 diff --git a/src/posix/jattach.c b/src/posix/jattach.c index 53d9dfb..a8a851e 100644 --- a/src/posix/jattach.c +++ b/src/posix/jattach.c @@ -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. @@ -22,12 +22,14 @@ 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 [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