xref: /csrg-svn/lib/libc/gen/nice.c (revision 38472)
121329Sdist /*
2*38472Sbostic  * Copyright (c) 1983 The Regents of the University of California.
3*38472Sbostic  * All rights reserved.
4*38472Sbostic  *
5*38472Sbostic  * Redistribution and use in source and binary forms are permitted
6*38472Sbostic  * provided that the above copyright notice and this paragraph are
7*38472Sbostic  * duplicated in all such forms and that any documentation,
8*38472Sbostic  * advertising materials, and other materials related to such
9*38472Sbostic  * distribution and use acknowledge that the software was developed
10*38472Sbostic  * by the University of California, Berkeley.  The name of the
11*38472Sbostic  * University may not be used to endorse or promote products derived
12*38472Sbostic  * from this software without specific prior written permission.
13*38472Sbostic  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
14*38472Sbostic  * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
15*38472Sbostic  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
1621329Sdist  */
1712842Ssam 
1826518Sdonn #if defined(LIBC_SCCS) && !defined(lint)
19*38472Sbostic static char sccsid[] = "@(#)nice.c	5.3 (Berkeley) 07/18/89";
20*38472Sbostic #endif /* LIBC_SCCS and not lint */
2121329Sdist 
2212842Ssam #include <sys/time.h>
2312842Ssam #include <sys/resource.h>
2412842Ssam 
2512842Ssam /*
2612842Ssam  * Backwards compatible nice.
2712842Ssam  */
2812842Ssam nice(incr)
2912842Ssam 	int incr;
3012842Ssam {
3112842Ssam 	int prio;
3212842Ssam 	extern int errno;
3312842Ssam 
3412842Ssam 	errno = 0;
3512842Ssam 	prio = getpriority(PRIO_PROCESS, 0);
3612842Ssam 	if (prio == -1 && errno)
3712842Ssam 		return (-1);
3812842Ssam 	return (setpriority(PRIO_PROCESS, 0, prio + incr));
3912842Ssam }
40