Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 4 Nov 2003 19:58:53 +0000
From:      Matthew Seaman <m.seaman@infracaninophile.co.uk>
To:        Zev Thompson <zevt@schemasoft.com>
Cc:        freebsd-questions@freebsd.org
Subject:   Re: Recursive renice?
Message-ID:  <20031104195853.GA1064@happy-idiot-talk.infracaninophile.co.uk>
In-Reply-To: <B55D6E30-0EFC-11D8-AABE-000A27AFDA88@schemasoft.com>
References:  <B55D6E30-0EFC-11D8-AABE-000A27AFDA88@schemasoft.com>

next in thread | previous in thread | raw e-mail | index | archive | help

--PNTmBPCT7hxwcZjr
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable

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

	Cheers,

	Matthew=09

--=20
Dr Matthew J Seaman MA, D.Phil.                       26 The Paddocks
                                                      Savill Way
PGP: http://www.infracaninophile.co.uk/pgpkey         Marlow
Tel: +44 1628 476614                                  Bucks., SL7 1TH UK

--PNTmBPCT7hxwcZjr
Content-Type: application/pgp-signature
Content-Disposition: inline

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.3 (FreeBSD)

iD8DBQE/qAT9dtESqEQa7a0RAu9kAJ9GVOPA6ttrcdF/wFZ5HKS7rRSFBACffRSO
S/yhp0z5bXOpYTpycbjatDk=
=U5NL
-----END PGP SIGNATURE-----

--PNTmBPCT7hxwcZjr--



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20031104195853.GA1064>