Shell { public static void destroyAllShellProcesses() { synchronized (CHILD_SHELLS) { for (Shell shell : CHILD_SHELLS.keySet()) { if (shell.getProcess() != null) { shell.getProcess().destroy(); } } CHILD_SHELLS.clear(); } } protected  Shell(); protected  Shell(long interval); protected  Shell(long interval, boolean redirectErrorStream); @Deprecated static boolean isJava7OrAbove(); static boolean isJavaVersionAtLeast(int version); static void checkWindowsCommandLineLength(String...commands); static String[] getGroupsCommand(); static String[] getGroupsForUserCommand(final String user); static String[] getGroupsIDForUserCommand(final String user); static String[] getUsersForNetgroupCommand(final String netgroup); static String[] getGetPermissionCommand(); static String[] getSetPermissionCommand(String perm, boolean recursive); static String[] getSetPermissionCommand(String perm,
                                                 boolean recursive,
                                                 String file); static String[] getSetOwnerCommand(String owner); static String[] getSymlinkCommand(String target, String link); static String[] getReadlinkCommand(String link); static String[] getCheckProcessIsAliveCommand(String pid); static String[] getSignalKillCommand(int code, String pid); static String getEnvironmentVariableRegex(); static File appendScriptExtension(File parent, String basename); static String appendScriptExtension(String basename); static String[] getRunScriptCommand(File script); static String getHadoopHome(); static File getQualifiedBin(String executable); static String getQualifiedBinPath(String executable); static boolean hasWinutilsPath(); static String getWinUtilsPath(); static File getWinUtilsFile(); static boolean checkIsBashSupported(); String getEnvironment(String env); Process getProcess(); int getExitCode(); Thread getWaitingThread(); boolean isTimedOut(); static String execCommand(String ... cmd); static String execCommand(Map<String, String> env, String[] cmd,
      long timeout); static String execCommand(Map<String,String> env, String ... cmd); static void destroyAllShellProcesses(); static Set<Shell> getAllShells(); static Long getMemlockLimit(Long ulimit); static final Logger LOG; static final String SYSPROP_HADOOP_HOME_DIR; static final String ENV_HADOOP_HOME; static final int WINDOWS_MAX_SHELL_LENGTH; @Deprecated
  static final int WINDOWS_MAX_SHELL_LENGHT; static final String USER_NAME_COMMAND; static final Object WindowsProcessLaunchLock; static final OSType osType; static final boolean WINDOWS; static final boolean SOLARIS; static final boolean MAC; static final boolean FREEBSD; static final boolean LINUX; static final boolean OTHER; static final boolean PPC_64; static final String ENV_NAME_REGEX; static final String SET_PERMISSION_COMMAND; static final String SET_OWNER_COMMAND; static final String SET_GROUP_COMMAND; static final String LINK_COMMAND; static final String READ_LINK_COMMAND; @Deprecated
  static final String WINUTILS; static final boolean isSetsidAvailable; static final String TOKEN_SEPARATOR_REGEX; }
@Test(timeout=120000) public void testDestroyAllShellProcesses() throws Throwable { Assume.assumeFalse(WINDOWS); StringBuffer sleepCommand = new StringBuffer(); sleepCommand.append("sleep 200"); String[] shellCmd = {"bash", "-c", sleepCommand.toString()}; final ShellCommandExecutor shexc1 = new ShellCommandExecutor(shellCmd); final ShellCommandExecutor shexc2 = new ShellCommandExecutor(shellCmd); Thread shellThread1 = new Thread() { @Override public void run() { try { shexc1.execute(); } catch(IOException ioe) { } } }; Thread shellThread2 = new Thread() { @Override public void run() { try { shexc2.execute(); } catch(IOException ioe) { } } }; shellThread1.start(); shellThread2.start(); GenericTestUtils.waitFor(new Supplier<Boolean>() { @Override public Boolean get() { return shexc1.getProcess() != null; } }, 10, 10000); GenericTestUtils.waitFor(new Supplier<Boolean>() { @Override public Boolean get() { return shexc2.getProcess() != null; } }, 10, 10000); Shell.destroyAllShellProcesses(); shexc1.getProcess().waitFor(); shexc2.getProcess().waitFor(); }