Ignore:
Timestamp:
Jan 1, 2014, 12:47:38 AM (7 years ago)
Author:
Bruno Cornec
Message:
  • Update mindi-busybox to 1.21.1
File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/3.2/mindi-busybox/miscutils/chrt.c

    r2725 r3232  
    66 * Licensed under GPLv2 or later, see file LICENSE in this source tree.
    77 */
     8
     9//usage:#define chrt_trivial_usage
     10//usage:       "[-prfom] [PRIO] [PID | PROG ARGS]"
     11//usage:#define chrt_full_usage "\n\n"
     12//usage:       "Change scheduling priority and class for a process\n"
     13//usage:     "\n    -p  Operate on PID"
     14//usage:     "\n    -r  Set SCHED_RR class"
     15//usage:     "\n    -f  Set SCHED_FIFO class"
     16//usage:     "\n    -o  Set SCHED_OTHER class"
     17//usage:     "\n    -m  Show min/max priorities"
     18//usage:
     19//usage:#define chrt_example_usage
     20//usage:       "$ chrt -r 4 sleep 900; x=$!\n"
     21//usage:       "$ chrt -f -p 3 $x\n"
     22//usage:       "You need CAP_SYS_NICE privileges to set scheduling attributes of a process"
     23
    824#include <sched.h>
    925#include "libbb.h"
     
    5470    int policy = SCHED_RR;
    5571
    56     /* at least 1 arg; only one policy accepted */
    57     opt_complementary = "-1:r--fo:f--ro:r--fo";
     72    /* only one policy accepted */
     73    opt_complementary = "r--fo:f--ro:o--rf";
    5874    opt = getopt32(argv, "+mprfo");
     75    if (opt & OPT_m) { /* print min/max and exit */
     76        show_min_max(SCHED_FIFO);
     77        show_min_max(SCHED_RR);
     78        show_min_max(SCHED_OTHER);
     79        fflush_stdout_and_exit(EXIT_SUCCESS);
     80    }
    5981    if (opt & OPT_r)
    6082        policy = SCHED_RR;
     
    6385    if (opt & OPT_o)
    6486        policy = SCHED_OTHER;
    65     if (opt & OPT_m) { /* print min/max */
    66         show_min_max(SCHED_FIFO);
    67         show_min_max(SCHED_RR);
    68         show_min_max(SCHED_OTHER);
    69         fflush_stdout_and_exit(EXIT_SUCCESS);
    70     }
    7187
    7288    argv += optind;
     89    if (!argv[0])
     90        bb_show_usage();
    7391    if (opt & OPT_p) {
    7492        pid_str = *argv++;
     
    91109        pol = sched_getscheduler(pid);
    92110        if (pol < 0)
    93             bb_perror_msg_and_die("can't %cet pid %d's policy", 'g', pid);
     111            bb_perror_msg_and_die("can't %cet pid %d's policy", 'g', (int)pid);
    94112        printf("pid %d's %s scheduling policy: %s\n",
    95113                pid, current_new, policies[pol].name);
    96114        if (sched_getparam(pid, &sp))
    97             bb_perror_msg_and_die("can't get pid %d's attributes", pid);
     115            bb_perror_msg_and_die("can't get pid %d's attributes", (int)pid);
    98116        printf("pid %d's %s scheduling priority: %d\n",
    99                 pid, current_new, sp.sched_priority);
     117                (int)pid, current_new, sp.sched_priority);
    100118        if (!*argv) {
    101119            /* Either it was just "-p <pid>",
     
    116134
    117135    if (sched_setscheduler(pid, policy, &sp) < 0)
    118         bb_perror_msg_and_die("can't %cet pid %d's policy", 's', pid);
     136        bb_perror_msg_and_die("can't %cet pid %d's policy", 's', (int)pid);
    119137
    120138    if (!argv[0]) /* "-p <priority> <pid> [...]" */
Note: See TracChangeset for help on using the changeset viewer.