[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: native nice command
From: |
Andreas Kusalananda Kähäri |
Subject: |
Re: native nice command |
Date: |
Wed, 2 Mar 2022 18:41:52 +0100 |
On Wed, Mar 02, 2022 at 06:34:03AM -0600, Peng Yu wrote:
> Hi,
>
> Normally nice is an external program. Is it possible to make it a
> builtin, so that when a bash function is called, any external commands
> called by the function will be niced? If a function is called to run
> in the background, that background bash process is also niced? Thanks.
>
> --
> Regards,
> Peng
Since the niceness value is something that is attached to a *process*
and is inherited by its child processes, and since functions are
run within the current shell process, you are looking for a way to
temporarily increase the niceness value of the current shell, and
then restore it to it's original value, without being a root user?
Ordinarily, you have to bo root to decrease the niceness value of a
process.
You don't post any example code, but could we assume that you want
something like the following?
foo () { echo 'running nicely'; var='ok'; }
unset -v ok
nice foo
printf 'Expecting "ok": "%s"\n' "$var"
Could you provide an example that shows what you are working with and
further explains what you need to do?
--
Andreas (Kusalananda) Kähäri
SciLifeLab, NBIS, ICM
Uppsala University, Sweden
.