OSDN Git Service

Update README
[linuxjm/LDP_man-pages.git] / original / man2 / nice.2
1 .\" Copyright (c) 1992 Drew Eckhardt <drew@cs.colorado.edu>, March 28, 1992
2 .\"
3 .\" %%%LICENSE_START(VERBATIM)
4 .\" Permission is granted to make and distribute verbatim copies of this
5 .\" manual provided the copyright notice and this permission notice are
6 .\" preserved on all copies.
7 .\"
8 .\" Permission is granted to copy and distribute modified versions of this
9 .\" manual under the conditions for verbatim copying, provided that the
10 .\" entire resulting derived work is distributed under the terms of a
11 .\" permission notice identical to this one.
12 .\"
13 .\" Since the Linux kernel and libraries are constantly changing, this
14 .\" manual page may be incorrect or out-of-date.  The author(s) assume no
15 .\" responsibility for errors or omissions, or for damages resulting from
16 .\" the use of the information contained herein.  The author(s) may not
17 .\" have taken the same level of care in the production of this manual,
18 .\" which is licensed free of charge, as they might when working
19 .\" professionally.
20 .\"
21 .\" Formatted or processed versions of this manual, if unaccompanied by
22 .\" the source, must acknowledge the copyright and authors of this work.
23 .\" %%%LICENSE_END
24 .\"
25 .\" Modified by Michael Haardt <michael@moria.de>
26 .\" Modified 1993-07-24 by Rik Faith <faith@cs.unc.edu>
27 .\" Modified 1996-11-04 by Eric S. Raymond <esr@thyrsus.com>
28 .\" Modified 2001-06-04 by aeb
29 .\" Modified 2004-05-27 by Michael Kerrisk <mtk.manpages@gmail.com>
30 .\"
31 .TH NICE 2 2014-04-28 "Linux" "Linux Programmer's Manual"
32 .SH NAME
33 nice \- change process priority
34 .SH SYNOPSIS
35 .B #include <unistd.h>
36 .sp
37 .BI "int nice(int " inc );
38 .sp
39 .in -4n
40 Feature Test Macro Requirements for glibc (see
41 .BR feature_test_macros (7)):
42 .in
43 .sp
44 .BR nice ():
45 _BSD_SOURCE || _SVID_SOURCE || _XOPEN_SOURCE
46 .SH DESCRIPTION
47 .BR nice ()
48 adds
49 .I inc
50 to the nice value for the calling process.
51 (A higher nice value means a low priority.)
52 Only the super\%user may specify a negative increment,
53 or priority increase.
54 The range for nice values is described in
55 .BR getpriority (2).
56 .SH RETURN VALUE
57 On success, the new nice value is returned (but see NOTES below).
58 On error, \-1 is returned, and
59 .I errno
60 is set appropriately.
61 .SH ERRORS
62 .TP
63 .B EPERM
64 The calling process attempted to increase its priority by
65 supplying a negative
66 .I inc
67 but has insufficient privileges.
68 Under Linux, the
69 .B CAP_SYS_NICE
70 capability is required.
71 (But see the discussion of the
72 .B RLIMIT_NICE
73 resource limit in
74 .BR setrlimit (2).)
75 .SH CONFORMING TO
76 SVr4, 4.3BSD, POSIX.1-2001.
77 However, the Linux and (g)libc
78 (earlier than glibc 2.2.4) return value is nonstandard, see below.
79 SVr4 documents an additional
80 .B EINVAL
81 error code.
82 .SH NOTES
83 SUSv2 and POSIX.1-2001 specify that
84 .BR nice ()
85 should return the new nice value.
86 However, the Linux syscall and the
87 .BR nice ()
88 library function provided in older versions of (g)libc
89 (earlier than glibc 2.2.4) return 0 on success.
90 The new nice value can be found using
91 .BR getpriority (2).
92
93 Since glibc 2.2.4,
94 .BR nice ()
95 is implemented as a library function that calls
96 .BR getpriority (2)
97 to obtain the new nice value to be returned to the caller.
98 With this implementation,
99 a successful call can legitimately return \-1.
100 To reliably detect an error, set
101 .I errno
102 to 0 before the call, and check its value when
103 .BR nice ()
104 returns \-1.
105 .SH SEE ALSO
106 .BR nice (1),
107 .BR renice (1),
108 .BR fork (2),
109 .BR getpriority (2),
110 .BR setpriority (2),
111 .BR capabilities (7),
112 .BR sched (7)
113 .SH COLOPHON
114 This page is part of release 3.79 of the Linux
115 .I man-pages
116 project.
117 A description of the project,
118 information about reporting bugs,
119 and the latest version of this page,
120 can be found at
121 \%http://www.kernel.org/doc/man\-pages/.