Subject: lib/17156: nice(3) doesn't match standard nor documentation
To: None <gnats-bugs@gnats.netbsd.org>
From: None <M.Drochner@fz-juelich.de>
List: netbsd-bugs
Date: 06/03/2002 20:13:50
>Number:         17156
>Category:       lib
>Synopsis:       nice(3) doesn't match standard nor documentation
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    lib-bug-people
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Mon Jun 03 11:14:01 PDT 2002
>Closed-Date:
>Last-Modified:
>Originator:     Matthias Drochner
>Release:        NetBSD 1.6A
>Organization:
	KFA Juelich
>Environment:
System: NetBSD zelz26 1.6A NetBSD 1.6A (ZELZ26) #196: Thu May 30 14:27:21 MEST 2002 drochner@zelz26:/home/drochner/netbsd/sys/arch/i386/compile/ZELZ26 i386
Architecture: i386
Machine: i386
>Description:
	nice(3) is supposed ro return the new priority.
Instead it returns the result of setpriority(2) which is used in the
implementation.
>How-To-Repeat:
	A small test program:
int
main()
{
        int a = nice(1);
        printf("%d %d\n", a, nice(2));
        return (0);
}
for us:
$ ./a.out
0 0
$ nice -5 ./a.out
0 0
it should:
$ ./a.out
1 3
$ nice -5 ./a.out
6 8
>Fix:
	Either document the deviand behaviour (as Linux does), or:
*** nice.c.~1.9.~	Sun Jan 23 14:46:56 2000
--- nice.c	Mon Jun  3 19:21:20 2002
***************
*** 66,70 ****
  	prio = getpriority(PRIO_PROCESS, 0);
  	if (prio == -1 && errno)
  		return (-1);
! 	return (setpriority(PRIO_PROCESS, 0, prio + incr));
  }
--- 66,72 ----
  	prio = getpriority(PRIO_PROCESS, 0);
  	if (prio == -1 && errno)
  		return (-1);
! 	if (setpriority(PRIO_PROCESS, 0, prio + incr) != 0)
! 		return (-1);
! 	return (getpriority(PRIO_PROCESS, 0));
  }

>Release-Note:
>Audit-Trail:
>Unformatted: