Created
July 28, 2017 00:48
-
-
Save tkfx/f591f58c18e462ff3e6adb0147331abd to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public static void main(String[] args) throws Exception { | |
| Process proc = Runtime.getRuntime().exec(new String[] { | |
| "/bin/sh", | |
| "-c", | |
| "echo $PPID" | |
| }); | |
| if (proc.waitFor() == 0) { | |
| InputStream in = proc.getInputStream(); | |
| int available = in.available(); | |
| byte[] outputBytes = new byte[available]; | |
| in.read(outputBytes); | |
| String pid = new String(outputBytes); | |
| System.out.println("Your pid is " + pid); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment