view toys/nice.c @ 402:2551e517b800

Expand comments.
author Rob Landley <>
date Sat, 14 Jan 2012 23:28:15 -0600
parents 633a5bf9509d
children d3ca5e15e457
line wrap: on
line source

/* vi: set sw=4 ts=4:
 * 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 (lowest
	  priority) to -19 (highest).  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.

#include "toys.h"

// Hello doesn't use these globals, they're here for example/skeleton purposes.

	long priority;

#define TT this.nice

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

	if (getpriority(PRIO_PROCESS, getpid()) != TT.priority)
		perror_exit("Can't set priority");