Commit Graph

39 Commits

Author SHA1 Message Date
Karel Zak 2c308875a7 misc: consolidate version printing and close_stdout()
Signed-off-by: Karel Zak <kzak@redhat.com>
2019-04-16 15:14:13 +02:00
Karel Zak 61b6222269 schedutils: use errexec()
Signed-off-by: Karel Zak <kzak@redhat.com>
2018-02-01 15:40:59 +01:00
Ruediger Meier f45f3ec34a misc: consolidate macro style USAGE_HELP_OPTIONS
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>
2017-06-29 16:54:33 +02:00
Ruediger Meier b305445495 misc: consolidate all --help option descriptions
Now we are always using the same text also for commands
which had still hardcoded descriptions or where we can't
use the standard print_usage_help_options macro.

Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
2017-06-27 12:28:36 +02:00
Ruediger Meier b1a294c448 misc: introduce print_usage_help_options()
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>
2017-06-27 12:26:19 +02:00
Ruediger Meier 6e1eda6f22 misc: never use usage(stderr)
Here we fix all cases where we have usage(FILE*)
functions.

Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
2017-06-26 14:38:24 +02:00
Karel Zak 6433fcad71 taskset: don't use zero PID in messages
The pid 0 is technically correct, but very confusing for end users. Use
getpid() in the messages.

Addresses: https://github.com/karelzak/util-linux/issues/413
Signed-off-by: Karel Zak <kzak@redhat.com>
2017-02-10 11:46:37 +01:00
Karel Zak 677ec86cef Use --help suggestion on invalid option
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>
2016-12-19 13:13:34 +01:00
Benno Schulenberg 451dbcfae1 textual: add a docstring to most of the utilities
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>
2015-01-06 11:27:38 +01:00
Sami Kerola a587cc5520 textual: use manual tail usage() macro
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2014-10-01 12:33:24 +02:00
Sami Kerola f627750083 textual: use version printing macro everywhere
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>
2014-10-01 12:33:23 +02:00
Benno Schulenberg a7560c0655 textual: make the license of chrt and taskset slightly more explicit
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>
2014-08-20 10:47:09 +02:00
Daniel Stodden d9b22d179a schedutils: don't apply -a without -p
The unsuspecting user might use taskset -a mask command. Behavior then
is to exec with no affinity applied at all. Better handled by ignoring
all_tasks if no pid was given.

Signed-off-by: Daniel Stodden <daniel.stodden@gmail.com>
2013-03-26 12:37:55 +01:00
Sami Kerola 07ff972eb6 translation: unify exec error messages
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2013-02-06 11:51:17 +01:00
Benno Schulenberg 8c219bf463 textual: gettextize several overlooked messages
Also improve the clarity of some of them.

Signed-off-by: Benno Schulenberg <bensberg@justemail.net>
2013-01-25 11:47:29 +01:00
Benno Schulenberg c602fe5a8e textual: tag two bug messages as "internal error"
Signed-off-by: Benno Schulenberg <bensberg@justemail.net>
2013-01-25 11:47:28 +01:00
Karel Zak 630ed89d5a schedutils: cleanup strtoxx_or_err()
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-05-15 17:45:05 +02:00
Sami Kerola ed8ec2a65d schedutils: verify writing to streams was successful
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2012-04-04 19:51:32 +02:00
Sami Kerola 7cebf0bb4f docs: corrections to FSF license files, and postal address
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>
2012-02-24 14:13:35 +01:00
Sami Kerola 2f5a248420 taskset: use appropriate variable type [cppcheck]
[schedutils/taskset.c:182]: (style) Checking if unsigned variable 'ncpus' is less than zero.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2012-02-08 14:13:34 +01:00
Heiko Carstens b16f615afb cpuset: add option to allow cpulist_parse() to fail
This is a preparation patch for chcpu. If a cpu should be added to
a cpu_set where the cpu doesn't fit into the cpu_set this got silently
ignored.
Since the cpu-list is user space provided it should be checked if cpus
are specified that are completely out of range of the system.
In order to do that add a parameter which specifies if cpulist_parse()
should fail if it parses a cpu-list with "impossible" cpus.
The current callers have been converted so they behave like before.

Signed-off-by: Heiko Carstens <heiko.carstens@de.ibm.com>
2011-08-15 07:52:44 +02:00
Karel Zak 9feec79cc5 misc: use unsigned int for bit-fileds
Reported-by: Sami Kerola <kerolasa@iki.fi>
Signed-off-by: Karel Zak <kzak@redhat.com>
2011-07-29 10:51:06 +02:00
Sami Kerola 02ad010012 taskset: coding style fixes
Reindentation and deletion of few empty lines etc. There is no
actual code changes in this patch.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2011-07-21 17:30:24 +02:00
Sami Kerola 6f45c0e9ff taskset: include-what-you-use header check
taskset.c should add these lines:
 #include <sched.h>   for sched_getaffinity, etc
 #include <stddef.h>  for size_t
 #include <string.h>  for memset

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2011-07-21 17:29:38 +02:00
Davidlohr Bueso 42708f12f0 taskset: make threads aware
Add a new '-a' option to view/modify the CPU affinity for an entire
group of threads belonging to a given PID.  We create two new
functions, print_affinity() and do_taskset() for code simplification.

Example:

zeus@jilguero:~/src/util-linux/schedutils$ ./taskset -a -p 01 3142
pid 3142's current affinity mask: 2
pid 3142's new affinity mask: 1
pid 3164's current affinity mask: 2
pid 3164's new affinity mask: 1
pid 854's current affinity mask: 2
pid 854's new affinity mask: 1

[kzak@redhat.com: - clean up
                  - move variables to struct taskset]

Signed-off-by: Davidlohr Bueso <dave@gnu.org>
Tested-by: Jonathan Gonzalez <zeus@gnu.org>
Signed-off-by: Karel Zak <kzak@redhat.com>
2011-05-11 16:17:56 +02:00
Davidlohr Bueso dd29a76293 taskset: use xalloc lib
Signed-off-by: Davidlohr Bueso <dave@gnu.org>
2011-05-11 10:06:58 +02:00
Karel Zak 6c7d5ae9a2 move struct option to .rodata
It does not make sense to have writable large arrays of "struct
option" on the stack.

Signed-off-by: Karel Zak <kzak@redhat.com>
2011-03-03 15:00:30 +01:00
Fabian Groffen eb76ca98b0 build-sys: provide alternatives for err, errx, warn and warnx
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>
2011-02-14 17:45:24 +01:00
Davidlohr Bueso f2f0dcaf11 schedutils: remove unneeded header files
Signed-off-by: Davidlohr Bueso <dave@gnu.org>
2011-02-08 16:23:28 +01:00
Davidlohr Bueso 8abcf29002 lib: [strutils] general purpose string handling functions
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>
2010-11-23 21:06:49 +01:00
Karel Zak 2429509658 taskset: proper numbers parsing
Reported-by: Davidlohr Bueso <dave@gnu.org>
Signed-off-by: Karel Zak <kzak@redhat.com>
2010-09-30 23:29:14 +02:00
Karel Zak bae91ecf07 taskset: move NR_CPUS determination to lib/cpuset.c
Signed-off-by: Karel Zak <kzak@redhat.com>
2010-06-01 11:11:26 +02:00
Karel Zak de87877662 taskset: add NLS support, use err.h, cleanup
Signed-off-by: Karel Zak <kzak@redhat.com>
2010-06-01 11:10:01 +02:00
Karel Zak ff5a6d2067 taskset: use libc based cpu_set_t
The glibc already supports dynamically allocated CPU sets. We don't
have to maintains our private non-compatible implementation.

Signed-off-by: Karel Zak <kzak@redhat.com>
2010-06-01 11:06:50 +02:00
Karel Zak efcb71f8ff taskset: move bitmap routines to lib/cpuset.c
Signed-off-by: Karel Zak <kzak@redhat.com>
2010-06-01 11:04:44 +02:00
Karel Zak bf928360f2 build-sys: remove hardcoded _GNU_SOURCE
We have AC_GNU_SOURCE, so we needn't any extra hardcoded _GNU_SOURCE.

Signed-off-by: Karel Zak <kzak@redhat.com>
2007-09-20 00:57:01 +02:00
Cliff Wickman f7e3dc0533 taskset: independent of hardcoded NR_CPUS max.
This patch makes the taskset command independent of the system's maximum
number of cpus (CONFIG_NR_CPUS).  The maximum for CONFIG_NR_CPUS is a
moving target.

With this patch the size of the systems's cpumask_t is gotten from
sched_getaffinity(2).

This patch uses variable length bitmasks borrowed from Paul Jackson's
variable size bitmask routines (hence I kept his copyright notice).
This replaces the use of the glibc CPU_SETSIZE, CPU_SET, CPU_ZERO and
CPU_ISSET macros which depend on a hardcoded size for cpu_set_t.

(also fixes one little nit: the -V option is "-v" in the built-in help, so
 changed the built-in help)

Signed-off-by: Cliff Wickman <cpw@sgi.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
2007-06-19 15:00:10 +02:00
Karel Zak baf39af15b Imported from util-linux-2.13-pre2 tarball. 2006-12-07 00:26:58 +01:00
Karel Zak 48d7b13a1e Imported from util-linux-2.13-pre1 tarball. 2006-12-07 00:26:54 +01:00