[BACK]Return to nice.c CVS log [TXT][DIR] Up to [local] / src / usr.bin / nice

Diff for /src/usr.bin/nice/nice.c between version 1.13 and 1.14

version 1.13, 2014/02/13 20:43:29 version 1.14, 2014/02/13 20:51:10
Line 47 
Line 47 
 int  int
 main(int argc, char *argv[])  main(int argc, char *argv[])
 {  {
         int niceness = DEFNICE;          const char *errstr;
           int prio = DEFNICE;
         int c;          int c;
   
         setlocale(LC_ALL, "");          setlocale(LC_ALL, "");
   
         /* handle obsolete -number syntax */          /* handle obsolete -number syntax */
         if (argc > 1 && argv[1][0] == '-' && isdigit((unsigned char)argv[1][1])) {          if (argc > 1 && argv[1][0] == '-' &&
                 niceness = atoi(argv[1] + 1);              isdigit((unsigned char)argv[1][1])) {
                   prio = strtonum(argv[1] + 1, PRIO_MIN, PRIO_MAX, &errstr);
                   if (errstr)
                           errx(1, "increment is %s", errstr);
                 argc--;                  argc--;
                 argv++;                  argv++;
         }          }
Line 62 
Line 66 
         while ((c = getopt (argc, argv, "n:")) != -1) {          while ((c = getopt (argc, argv, "n:")) != -1) {
                 switch (c) {                  switch (c) {
                 case 'n':                  case 'n':
                         niceness = atoi(optarg);                          prio = strtonum(optarg, PRIO_MIN, PRIO_MAX, &errstr);
                           if (errstr)
                                   errx(1, "increment is %s", errstr);
                         break;                          break;
   
                 case '?':                  case '?':
                 default:                  default:
                         usage();                          usage();
Line 78 
Line 83 
                 usage();                  usage();
   
         errno = 0;          errno = 0;
         niceness += getpriority(PRIO_PROCESS, 0);          prio += getpriority(PRIO_PROCESS, 0);
         if (errno) {          if (errno) {
                 err(1, "getpriority");                  err(1, "getpriority");
                 /* NOTREACHED */                  /* NOTREACHED */
         }          }
         if (setpriority(PRIO_PROCESS, 0, niceness))          if (setpriority(PRIO_PROCESS, 0, prio))
                 warn("setpriority");                  warn("setpriority");
   
         execvp(argv[0], &argv[0]);          execvp(argv[0], &argv[0]);

Legend:
Removed from v.1.13  
changed lines
  Added in v.1.14