Asked  7 Months ago    Answers:  5   Viewed   20 times

I want to kill a whole process tree. What is the best way to do this using any common scripting languages? I am looking for a simple solution.



You don't say if the tree you want to kill is a single process group. (This is often the case if the tree is the result of forking from a server start or a shell command line.) You can discover process groups using GNU ps as follows:

 ps x -o  "%p %r %y %x %c "

If it is a process group you want to kill, just use the kill(1) command but instead of giving it a process number, give it the negation of the group number. For example to kill every process in group 5112, use kill -TERM -- -5112.

Tuesday, June 1, 2021
answered 7 Months ago

Is the source of ps and other process tools. They do indeed use proc (indicating it is probably the conventional and best way). Their source is quite readable. The file


May be useful. Also a useful suggestion as posted by ephemient is linking to the API provided by libproc, which should be available in your repo (or already installed I would say) but you will need the "-dev" variation for the headers and what-not.

Good Luck

Tuesday, June 1, 2021
answered 7 Months ago

When a process terminates its parent process must acknowledge this using the wait or waitpid function. These functions also return the exit status. After the call to wait or waitpid the process table entry is removed, and the exit status is no longer stored anywhere in the operating system. You should check if the software you use to start the process saves the exit status somewhere.

If the parent process has not acknowledged that the child has terminated you can read its exit status from the /proc file system: it is the last field in /proc/[pid]/stat. It is stored in the same format that wait returns it, so you have to divide by 256 to get the exit code. Also you probably have to be root.

Saturday, August 7, 2021
answered 4 Months ago

I would agree with Marc on using helpers but if you must avoid them then you could try something like the following:

<select id="View" name="View">
   <option value="1" <% if (something) { %> selected <% } %> >With issue covers</option>
   <option value="0" <% if (!something) { %> selected <% } %> >No issue covers</option>
Tuesday, August 24, 2021
answered 4 Months ago

You can override ConvertUtilsBean. The following code adds support for Enum, but you can do the same for Map:

BeanUtilsBean.setInstance(new BeanUtilsBean(new EnumAwareConvertUtilsBean()));

Class definitions:

public class EnumAwareConvertUtilsBean extends ConvertUtilsBean2 {

    private static final EnumConverter ENUM_CONVERTER = new EnumConverter();

    public Converter lookup(Class pClazz) {
        final Converter converter = super.lookup(pClazz);

        if (converter == null && pClazz.isEnum()) {
            return ENUM_CONVERTER;
        } else {
            return converter;


public class EnumConverter extends AbstractConverter {

    private static final Logger LOGGER = LoggerFactory.getLogger(EnumConverter.class);

    protected String convertToString(final Object pValue) throws Throwable {
        return ((Enum) pValue).name();

    protected Object convertToType(final Class pType, final Object pValue)
        throws Throwable
        // NOTE: Convert to String is handled elsewhere

        final Class<? extends Enum> type = pType;
        try {
            return Enum.valueOf(type, pValue.toString());
        } catch (final IllegalArgumentException e) {
            LOGGER.warn("No enum value ""
                + pValue
                + "" for "
                + type.getName());

        return null;

    protected Class getDefaultType() {
        return null;


I got the solution from reading the blog post and comments from

Thursday, November 11, 2021
answered 3 Weeks ago
Only authorized users can answer the question. Please sign in first, or register a free account.
Not the answer you're looking for? Browse other questions tagged :