You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@commons.apache.org by "maxxedev (via GitHub)" <gi...@apache.org> on 2024/11/30 06:55:15 UTC
[PR] Improve container detection if current process is pid 1 [commons-lang]
maxxedev opened a new pull request, #1322:
URL: https://github.com/apache/commons-lang/pull/1322
<!--
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
-->
Thanks for your contribution to [Apache Commons](https://commons.apache.org/)! Your help is appreciated!
Before you push a pull request, review this list:
- [x] Read the [contribution guidelines](CONTRIBUTING.md) for this project.
- [x] Run a successful build using the default [Maven](https://maven.apache.org/) goal with `mvn`; that's `mvn` on the command line by itself.
- [x] Write unit tests that match behavioral changes, where the tests fail if the changes to the runtime are not applied. This may not always be possible but is a best-practice.
- [x] Write a pull request description that is detailed enough to understand what the pull request does, how, and why.
- [x] Each commit in the pull request should have a meaningful subject line and body. Note that commits might be squashed by a maintainer on merge.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@commons.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Improve container detection if current process is pid 1 [commons-lang]
Posted by "maxxedev (via GitHub)" <gi...@apache.org>.
maxxedev commented on PR #1322:
URL: https://github.com/apache/commons-lang/pull/1322#issuecomment-2508890675
@ppkarwasz
> JVM will never have PID 1
JVM can certainly be PID 1 inside a container. Example:
```
$ cat App.java
public class App {
public static void main(String... args) {
var mxBean = java.lang.management.ManagementFactory.getRuntimeMXBean();
System.out.println(mxBean.getName());
}
}
$ docker run -it --entrypoint java -v `pwd`:/tmp/ openjdk:21 /tmp/App.java
1@afecfa5e25bb
```
> checking `/proc/1/environ` and the environment of the JVM is equivalent.
Yes, equivalent but perhaps reading from `System.getenv()` is a slight improvement by avoiding file i/o on procfs
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@commons.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Improve container detection if current process is pid 1 [commons-lang]
Posted by "maxxedev (via GitHub)" <gi...@apache.org>.
maxxedev closed pull request #1322: Improve container detection if current process is pid 1
URL: https://github.com/apache/commons-lang/pull/1322
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@commons.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Improve container detection if current process is pid 1 [commons-lang]
Posted by "ppkarwasz (via GitHub)" <gi...@apache.org>.
ppkarwasz commented on PR #1322:
URL: https://github.com/apache/commons-lang/pull/1322#issuecomment-2508895463
> > JVM will never have PID 1
>
> JVM can certainly be PID 1 inside a container. Example:
Point taken.
> > checking `/proc/1/environ` and the environment of the JVM is equivalent.
>
> Yes, equivalent but perhaps reading from `System.getenv()` is a slight improvement by avoiding file i/o on procfs
Your code requires the `java.management` Java module to handle a specific case that was already handled correctly by the previous code (which only requires `java.base`). IMHO this is not an improvement.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@commons.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Improve container detection if current process is pid 1 [commons-lang]
Posted by "ppkarwasz (via GitHub)" <gi...@apache.org>.
ppkarwasz commented on PR #1322:
URL: https://github.com/apache/commons-lang/pull/1322#issuecomment-2508866455
@maxxedev,
Can you explain in what consists the improvement? AFAIK the JVM will never have PID 1. Even if it does, checking `/proc/1/environ` and the environment of the JVM is equivalent.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@commons.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org