summaryrefslogtreecommitdiffstats
path: root/schedutils/chrt.c
Commit message (Collapse)AuthorAgeFilesLines
* misc: consolidate version printing and close_stdout()Karel Zak2019-04-161-3/+3
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* chrt: fix compiler warning [-Wmaybe-uninitialized]Karel Zak2018-02-201-1/+1
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* schedutils: use errexec()Karel Zak2018-02-011-1/+1
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* misc: consolidate macro style USAGE_HELP_OPTIONSRuediger Meier2017-06-291-2/+2
| | | | | | | | | changed in include/c.h and applied via sed: sed -i 's/fprintf.*\(USAGE_MAN_TAIL.*\)/printf(\1/' $(git ls-files -- "*.c") sed -i 's/print_usage_help_options\(.*\);/printf(USAGE_HELP_OPTIONS\1);/' $(git ls-files -- "*.c") Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
* misc: introduce print_usage_help_options()Ruediger Meier2017-06-271-2/+1Star
| | | | | | | | | | | | Consolidate --help and --version descriptions. We are now able to align them to the other options. We changed include/c.h. The rest of this patch was generated by sed, plus manually setting the right alignment numbers. We do not change anything but white spaces in the --help output. Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
* misc: never use usage(ERROR)Ruediger Meier2017-06-261-6/+8
| | | | | | | | | | We are using better/shorter error messages and somtimes also errtryhelp(). Here we fix all cases where the usage function took an int argument for exit_code. Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
* Use --help suggestion on invalid optionKarel Zak2016-12-191-5/+2Star
| | | | | | | | The current default is to print all usage() output. This is overkill in many case. Addresses: https://github.com/karelzak/util-linux/issues/338 Signed-off-by: Karel Zak <kzak@redhat.com>
* chrt: default to SCHED_RR policyAndreas Henriksson2016-12-051-1/+1
| | | | | | | | | | | | | | | | | This fixes a regression introduced in: commit 7a4ea5664edba98bff28adec3a9c3cfb5763a495 "chrt: add control struct" Previously (and as documented in the manpage) the default policy was SCHED_RR. Now it's implicitly SCHED_OTHER (0) as the value is not initialized explicitly anymore. Test-command: chrt 90 echo hello Reported-by: Patrick Pelissier <patrick.pelissier@gmail.com> Addresses: http://bugs.debian.org/846572 Signed-off-by: Andreas Henriksson <andreas@fatal.se>
* chrt: fix HAVE_SCHED_SETATTR fallback caseRuediger Meier2016-10-271-2/+3
| | | | | | | | | | | Broken since 6f27e449. We could not enter the fallback if HAVE_SCHED_SETATTR is not defined. Two gcc warnings made this issue visible: schedutils/chrt.c:247:1: warning: label 'fallback' defined but not used [-Wunused-label] schedutils/chrt.c:266:9: warning: 'policy' may be used uninitialized in this function [-Wuninitialized] Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
* chrt: follow nice setting, prefer sched_setscheduler()Karel Zak2016-10-031-16/+18
| | | | | | | | | | | | | | | | * do not reset 'nice' setting by sched_setattr(), if 'nice' setting is not zero then chrt ends with EPERM for non-root users: $ renice -n 5 -p $$; chrt -v -b 0 date 12475 (process ID) old priority 0, new priority 5 chrt: failed to set pid 0's policy: Operation not permitted * it seems more elegant to always use old sched_setscheduler() API for non-deadline policies; in this case we do not need getpriority() to keep 'nice' unchanged. Addresses: https://github.com/karelzak/util-linux/issues/359 Signed-off-by: Karel Zak <kzak@redhat.com>
* chrt: add fallback to be usable on kernels without sched_{get,set}attrKarel Zak2016-07-111-8/+43
| | | | | | | | | | We have fallback for compilation with/without proper glibc and kernel headers, but it's not enough, because people can switch between kernels with and without the syscalls. (For example RT kernels for RHEL/CentOS). Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=1353340 Signed-off-by: Karel Zak <kzak@redhat.com>
* tests: add chrt testKarel Zak2016-07-111-2/+2
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* chrt: validate priority before trying to use itSami Kerola2016-04-131-1/+5
| | | | | | | | | | | | | | | | Earlier message: $ chrt -i 1 ls chrt: failed to set pid 0's policy: Invalid argument basically told 'something failed', while the new one tries to be more helpful. $ chrt -i 1 ls chrt: unsupported priority value for the policy: 1: see --max for valid range Addresses: https://bugs.debian.org/791707 Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* chrt: make --sched-* short options to require an argumentSami Kerola2016-04-041-1/+1
| | | | | | | These options are expecting an argument, and the long options struct already required them. Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* chrt: restore removed ifdef SCHED_RESET_ON_FORKRuediger Meier2016-02-241-0/+4
| | | | | | They got lost in acde3a05. Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
* chrt: fix case SCHED_RRRuediger Meier2016-02-241-1/+1
| | | | | | Looks like the logic was mistakenly changed in acde3a05. Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
* chrt: use sched_getattr()Karel Zak2016-01-201-67/+92
|
* chrt: add support for SCHED_DEADLINEKarel Zak2016-01-201-24/+92
| | | | | | | | | | | | | | This patch introduces -d, --deadline -T, --sched-runtime -D, --sched-deadline -P, --sched-period command line options. The functionality is available only for Linux with sched_setattr() [kernel >=3.14] Signed-off-by: Karel Zak <kzak@redhat.com>
* chrt: use sched_setattr() if availableKarel Zak2016-01-201-7/+66
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* chrt: make usage more readableKarel Zak2016-01-191-1/+1
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* chrt: set function refactoringKarel Zak2016-01-191-19/+27
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* chrt: output function refactoringKarel Zak2016-01-191-16/+26
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* chrt: add control structKarel Zak2016-01-191-39/+45
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* chrt: slice up the usage text and normalize its layoutBenno Schulenberg2015-06-151-25/+28
| | | | Signed-off-by: Benno Schulenberg <bensberg@justemail.net>
* chrt: make the usage synopsis clearerBenno Schulenberg2015-06-151-1/+2
| | | | Signed-off-by: Benno Schulenberg <bensberg@justemail.net>
* chrt: fix --help inconsistencyKarel Zak2015-06-091-1/+1
| | | | | Reported-by: Martin Steigerwald <ms@teamix.de> Signed-off-by: Karel Zak <kzak@redhat.com>
* textual: add a docstring to most of the utilitiesBenno Schulenberg2015-01-061-1/+1
| | | | | | | | | This adds a concise description of a tool to its usage text. A first form of this patch was proposed by Steven Honeyman (see http://www.spinics.net/lists/util-linux-ng/msg09994.html). Signed-off-by: Benno Schulenberg <bensberg@justemail.net>
* textual: use manual tail usage() macroSami Kerola2014-10-011-0/+1
| | | | Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* textual: use version printing macro everywhereSami Kerola2014-10-011-2/+1Star
| | | | | | | Only mount, umount, and blkid remains not using the macro because they are print also library references. Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* textual: make the license of chrt and taskset slightly more explicitBenno Schulenberg2014-08-201-6/+4Star
| | | | | | | This makes it match the license of the man pages. While there, also tweak some other comment lines. Signed-off-by: Benno Schulenberg <bensberg@justemail.net>
* textual: fix several typos and angular brackets in messagesBenno Schulenberg2013-06-071-1/+1
| | | | Signed-off-by: Benno Schulenberg <bensberg@justemail.net>
* chrt: make command syntax easier to understand in usage()Sami Kerola2013-04-051-2/+2
| | | | | | | | And mention in manual that the default is referring to the internal default of this command, not the Linux system default. Manual page example also tries to be a little more complete how to use the command. Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* translation: unify exec error messagesSami Kerola2013-02-061-1/+0Star
| | | | Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* textual: gettextize several overlooked messagesBenno Schulenberg2013-01-251-2/+2
| | | | | | Also improve the clarity of some of them. Signed-off-by: Benno Schulenberg <bensberg@justemail.net>
* textual: fix typos in messagesYuri Chornoivan2012-09-041-1/+1
|
* schedutils: cleanup strtoxx_or_err()Karel Zak2012-05-151-2/+2
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* schedutils: verify writing to streams was successfulSami Kerola2012-04-041-1/+2
| | | | Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* docs: corrections to FSF license files, and postal addressSami Kerola2012-02-241-3/+3
| | | | | | | | | | | | | | The COPYING and Documentation/licenses/COPYING* files are being replaced by files from GNU web site. http://www.gnu.org/licenses/gpl-2.0.txt http://www.gnu.org/licenses/lgpl-2.1.txt Postal addresses to FSF in other files are updated to match with the address in license files. Reference: http://lists.gnu.org/archive/html/freefont-announce/2005-04/msg00001.html Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* chrt: add comment to keep static analysers happyKarel Zak2012-01-311-0/+1
|
* chrt: silently ignore -R if unsupportedKarel Zak2011-08-021-2/+2
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* chrt: add strings to use NLSSami Kerola2011-07-211-3/+3
| | | | | Signed-off-by: Sami Kerola <kerolasa@iki.fi> Signed-off-by: Karel Zak <kzak@redhat.com>
* chrt: coding style fixSami Kerola2011-07-211-20/+26
| | | | | | | Make horizontal list vertical and few other enhancements to readability. Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* chrt: data type compiler warning fixedSami Kerola2011-07-211-1/+1
| | | | | | | chrt.c:158:16: warning: comparison of integers of different signs: 'int' and 'unsigned long' [-Wsign-compare] Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* chrt: clarify use of -a optionDavidlohr Bueso2011-05-171-1/+1
| | | | | | | With this option we can operate on all the thread group of a process not just for changes, but also when obtaining information via sched_getscheduler(). Signed-off-by: Davidlohr Bueso <dave@gnu.org>
* chrt: allow to use --all-tasks when retrieve infoKarel Zak2011-05-051-4/+14
| | | | | | | | | | master thread: $ chrt --pid $(pidof firefox) all threads: $ chrt --all-tasks --pid $(pidof firefox) Signed-off-by: Karel Zak <kzak@redhat.com>
* chrt: make threads awareDavidlohr Bueso2011-05-051-4/+26
| | | | | | | | | | | | | | | | | | | | | | | | | Currently this program works only with the master thread. Add a '-t' option to propagate changes to the entire group of threads. Example: root@offworld:~/projects/util-linux/schedutils# ls /proc/2111/task/ 2111 2112 2119 2121 2138 2139 2159 2160 root@offworld:~/projects/util-linux/schedutils# ./chrt -p 2111 pid 2111's current scheduling policy: SCHED_RR pid 2111's current scheduling priority: 3 root@offworld:~/projects/util-linux/schedutils# ./chrt -t -p 2 2111 root@offworld:~/projects/util-linux/schedutils# ./chrt -p 2112 pid 2112's current scheduling policy: SCHED_RR pid 2112's current scheduling priority: 2 root@offworld:~/projects/util-linux/schedutils# ./chrt -p 2111 pid 2111's current scheduling policy: SCHED_RR pid 2111's current scheduling priority: 2 [kzak@redhat.com: - rename -t/--thread to -a/--all-tasks] Signed-off-by: Davidlohr Bueso <dave@gnu.org> Signed-off-by: Karel Zak <kzak@redhat.com>
* move struct option to .rodataKarel Zak2011-03-031-1/+1
| | | | | | | It does not make sense to have writable large arrays of "struct option" on the stack. Signed-off-by: Karel Zak <kzak@redhat.com>
* build-sys: provide alternatives for err, errx, warn and warnxFabian Groffen2011-02-141-1/+0Star
| | | | | | | | Solaris lacks err, errx, warn and warnx. This also means the err.h header doesn't exist. Removed err.h include from all files, and included err.h from c.h instead if it exists, otherwise alternatives are provided. Signed-off-by: Fabian Groffen <grobian@gentoo.org>
* lib: [strutils] general purpose string handling functionsDavidlohr Bueso2010-11-231-3/+3
| | | | | | | | | | | | | This patch replaces a few functions used throughout the source: * Renames getnum (from schedutils) to strtol_or_err * Moves strtosize (from lib/strtosize.c) * Moves xstrncpy (from include/xstrncpy.h) * Adds strnlen, strnchr and strndup if not available (remove it from libmount utils) A few Makefile.am files were modified to compile accordingly along with trivial renaming in schedutils source code. Signed-off-by: Davidlohr Bueso <dave@gnu.org>
* chrt: Add noreturn attribute to show_usage() functionMarek Polacek2010-10-291-1/+1
| | | | Signed-off-by: Marek Polacek <mmpolacek@gmail.com>