bug-coreutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Coreutils improvement: Recursive renice


From: Steven Augart
Subject: Re: Coreutils improvement: Recursive renice
Date: Fri, 3 Oct 2003 13:26:32 -0400


I disagree with Andreas.  Pidof will find the pids of the named programs.  That's a different thing from a pstree-type listing, which will show all inferiors to the original call to "make" or "ant".  For example, right now I have a cron-spawned job running on my workstation that performs nightly rebuilds of a software package:

nightly-rebuild(2788)---build(5710)---ant(5711)---java(5713)---java(5714)-+-java(5715)
                                                                          |-java(5716)
                                                                         |-java(5717)

                                                                          |-java(5718)
                                                                          |-java(5719)
                                                                          |-java(5720)
                                                                         |-java(5721)

                                                                          |-java(5806)---java(5807)
                                                                                                 |-java(5808)

                                                                          `-java(5809)


Pidof requires the real names of the executables that are running (the /proc/<number>/exe link).  In the case above, the first three processes (#2788, #5710, and 5711) are actually Bash programs being executed by /bin/bash.  And "pidof /bin/bash" would reach far beyond the three specific processes I would care about..  Also, there are other Java programs on the machine that I likewise do not wish to affect.  If I were running a C compilation under "make", there would be at least five different executables involved:
        /usr/local/bin/make
        /usr/local/bin/bash
        /usr/local/bin/gcc
        /usr/local/bin/cpp
        /usr/local/lib/gcc-lib/i686-pc-linux-gnu/3.3.1/cc1

Even if there were no other instances of those processes that I wanted to renice down, it would still be a significant burden.

I do think that perhaps pstree would be the logical candidate for extension.   It would certainly be generally useful to have a utility to list the pid #s of all the processes in a subtree rooted at a certain point.

In fact,  based on the above, I've just written such a utility, available at http://www.augart.com/Hacks/src/kids.sh
Its core is the following line of Bash:

        pstree -p $parent-process-id | sed -e 's/[^0-9]\+/ /g' -e 's/  //g' -e 's/  //g' -e 's/^ //' -e 's/ $//' | tr ' ' '\n'

The functionality would be handy for renice and so on:
        renice -R 5343
but does go against the Unix toolbox approach of:
        renice $(kids 5343)



Andreas Schwab <address@hidden>
Sent by: address@hidden

10/03/2003 11:22 AM

       
        To:        "Jonathan Fors" <address@hidden>
        cc:        address@hidden
        Subject:        Re: Coreutils improvement: Recursive renice



"Jonathan Fors" <address@hidden> writes:

> I have got a great idea to implement in the renice program. After trying
> to set another priority to a compilation job on my box I realized that I
> had to type about ten commands, reading the ps aux list every time to look
> up the process ID:s.

Try pidof(8).

Andreas.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]