Merge pull request #352 from garenchan/dev

More user-friendly prompts when selecting pid.
pull/353/head
hengyunabc 6 years ago committed by GitHub
commit 39b499793d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -12,6 +12,7 @@ import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.logging.Level;
import java.util.InputMismatchException;
import javax.xml.parsers.ParserConfigurationException;
@ -250,7 +251,12 @@ public class Bootstrap {
int pid = bootStrap.getPid();
// select pid
if (pid < 0) {
pid = ProcessUtils.select(bootStrap.isVerbose());
try {
pid = ProcessUtils.select(bootStrap.isVerbose());
} catch (InputMismatchException e) {
System.out.println("Please input an integer to select pid.");
System.exit(1);
}
if (pid < 0) {
System.out.println("Please select an avaliable pid.");
System.exit(1);

@ -12,6 +12,7 @@ import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.Scanner;
import java.util.InputMismatchException;
import com.taobao.arthas.common.AnsiLog;
import com.taobao.arthas.common.ExecutingCommand;
@ -45,7 +46,8 @@ public class ProcessUtils {
return PID;
}
public static int select(boolean v) {
@SuppressWarnings("resource")
public static int select(boolean v) throws InputMismatchException {
Map<Integer, String> processMap = listProcessByJps(v);
if (processMap.isEmpty()) {

Loading…
Cancel
Save