comparison toys/nice.c @ 649:2364ace48ab1

Bugfix from Avery Pennarun: getpriority() uses a different range than nice(), so follow thenice man page and zero errno then check it if nice returns -1.
author Rob Landley <rob@landley.net>
date Thu, 16 Aug 2012 22:24:30 -0500
parents b51faa4fe8e6
children
comparison
equal deleted inserted replaced
648:131571cf708c 649:2364ace48ab1
32 32
33 void nice_main(void) 33 void nice_main(void)
34 { 34 {
35 if (!toys.optflags) TT.priority = 10; 35 if (!toys.optflags) TT.priority = 10;
36 36
37 nice(TT.priority); 37 errno = 0;
38 if (getpriority(PRIO_PROCESS, getpid()) != TT.priority) 38 if (nice(TT.priority)==-1 && errno) perror_exit("Can't set priority");
39 perror_exit("Can't set priority");
40 39
41 xexec(toys.optargs); 40 xexec(toys.optargs);
42 } 41 }