Recursive renice?

Matthew Seaman m.seaman at
Tue Nov 4 11:59:11 PST 2003

On Tue, Nov 04, 2003 at 11:25:54AM -0800, Zev Thompson wrote:
> Hi all,
> I'm curious whether there's an easy way to renice(8) a process and all 
> of its children in one simple command. For example, I might start a 
> recursive make, which spawns lots of processes, and want them all to 
> change priority at once.
> The command I want is this:
> renice +10 -r process-ID
> Except for the fact that -r is not a valid flag. The pstree utility, in 
> the ports, seems like it might be a good start to hack this 
> functionality in. I searched google for "recursive renice" and found 
> someone had made a sed script, but it's for linux, where the pstree 
> output is different. Here's some example pstree output:
>  |             \-+- 14187 zevt gmake
>  |               \-+- 14189 zevt gmake all-recursive
>  |                 \-+- 14190 zevt /bin/sh -c set fnord ;
>  |                   \-+- 14807 zevt /bin/sh -c set fnord ;
> [etc.]
> Google result that's relevant:
> Any hints? Thanks in advance to any answers.

That's what 'renice -g pgrp' is for.  It's perhaps not quite as
flexible as you might like, as the only option is to renice a whole
process group -- however, this is the only way to renice a process
based on what it's parent processes are, other than by writing a
script to parse the output of ps(1) and applying renice several times
to affect a number of PIDs.

Generally for an interactive login, the process group includes your
login shell as process group leader and anything else you start up as
members of the process group.  The only exceptions are processes that
call setsid(2), which is commonly called as part of daemonizing a
process.  Under X, each xterm generally exists in it's own process
group, as do most X applications.  Use 'ps -j to obtain PGID values.



Dr Matthew J Seaman MA, D.Phil.                       26 The Paddocks
                                                      Savill Way
PGP:         Marlow
Tel: +44 1628 476614                                  Bucks., SL7 1TH UK
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 187 bytes
Desc: not available
Url :

More information about the freebsd-questions mailing list