view toys/posix/nice.c @ 1008:a55854bde872

su: cleanery * make help message more like others * s/TT\.(.)Argu/TT.\1/g * move environ to toys.h * simplify failure messages * clear password before quit * not check what execve returns * -lc
author Strake <>
date Sat, 17 Aug 2013 02:54:58 -0500
parents 144d5ba7d410
children cbb1aca81eca
line wrap: on
line source

/* nice.c - Run a program at a different niceness level.
 * Copyright 2010 Rob Landley <>
 * See


config NICE
  bool "nice"
  default y
    usage: nice [-n PRIORITY] command [args...]

    Run a command line at an increased or decreased scheduling priority.

    Higher numbers make a program yield more CPU time, from -20 (highest
    priority) to 19 (lowest).  By default processes inherit their parent's
    niceness (usually 0).  By default this command adds 10 to the parent's
    priority.  Only root can set a negative niceness level.

#define FOR_nice
#include "toys.h"

  long priority;

void nice_main(void)
  if (!toys.optflags) TT.priority = 10;

  errno = 0;
  if (nice(TT.priority)==-1 && errno) perror_exit("Can't set priority");