summaryrefslogtreecommitdiffstats
path: root/src/shared/cgroup-show.c (follow)
Commit message (Collapse)AuthorAgeFilesLines
* cgls: visually separate processes from cgroupsLennart Poettering2019-11-201-1/+1
| | | | | Let's show them in grey, since we generally want to focus on showing the cgroups much less than the processes in them.
* cgls: show delegation boundaries by underlining the cgroup in the outputLennart Poettering2019-11-201-3/+47
| | | | | | | | | | | | | This should help visualize where one manager's territory begins and another's starts. Do this by underlining (since it's a "cut" point an underline made most sense to me). Since underlining is not visible on the console let's also show an ellipses for all lines that are delegation boundaries. Unfortunately this all is not as useful as it appears. The "trusted.delegate" xattr is only visible to roo, which means "systemd-cgls" has be called as root to show the boundaries. Unfortunately cgroupfs doesn't support unprivileged xattrs on cgroups.
* tree-wide: drop string.h when string-util.h or friends are includedYu Watanabe2019-11-031-1/+0
|
* tree-wide: get rid of strappend()Lennart Poettering2019-07-121-2/+2
| | | | | It's a special case of strjoin(), so no need to keep both. In particular as typing strjoin() is even shoert than strappend().
* tree-wide: replace strjoin() with path_join()Yu Watanabe2019-06-201-1/+1
|
* Add 8bit-version of get_process_cmdline() and use in cgroup-show.cZbigniew Jędrzejewski-Szmek2019-05-221-1/+3
| | | | | | | | | | | This restores show_pid_array() output in legacy locales on the console. Only one call to get_process_cmdline() is changed, all others retain utf8-only mode. This affects systemd-cgls, systemctl status, etc, when working locally. Calls to get_process_cmdline() that cross a process boundary always use utf8. It's the callers responsibility to convert this to some encoding that they use. This means that we always pass utf8 over the bus.
* basic/process-util: convert bool arg to flagsZbigniew Jędrzejewski-Szmek2019-05-221-1/+1
| | | | In preparation for the next commit…
* Rework cmdline printing to use unicodeZbigniew Jędrzejewski-Szmek2019-05-221-7/+7
| | | | | | | | | | | | | | | | | | | | | | | | | The functions to retrieve and print process cmdlines were based on the assumption that they contain printable ASCII, and everything else should be filtered out. That assumption doesn't hold in today's world, where people are free to use unicode everywhere. This replaces the custom cmdline reading code with a more generic approach using utf8_escape_non_printable_full(). For kernel threads, truncation is done on the parenthesized name, so we'll get "[worker]", "[worker…]", …, "[w…]", "[…", "…" as we reduce the number of available columns. This implementation is most likely slower for very long cmdlines, but I don't think this is very important. The common case is to have short commandlines, and should print those properly. Absurdly long cmdlines are the exception, which needs to be handled correctly and safely, but speed is not too important. Fixes #12532. v2: - use size_t for the number of columns. This change propagates into various other functions that call get_process_cmdline(), increasing the size of the patch, but the changes are rather trivial.
* shared/cgroup-show: fix off-by-one in column countingZbigniew Jędrzejewski-Szmek2019-05-211-2/+2
| | | | | We'd get one column too many, and the trailing ellipsis would end up in the next row.
* util: split out sorting related calls to new sort-util.[ch]Lennart Poettering2019-03-131-0/+1
|
* locale-util: prefix special glyph enum values with SPECIAL_GLYPH_Lennart Poettering2018-12-141-5/+5
| | | | | | | This has been irritating me for quite a while: let's prefix these enum values with a common prefix, like we do for almost all other enums. No change in behaviour, just some renaming.
* util-lib: split out env file parsing code into env-file.cLennart Poettering2018-12-021-1/+1
| | | | | | It's quite complex, let's split this out. No code changes, just some file rearranging.
* tree-wide: remove various unused functionsLennart Poettering2018-12-021-20/+0
| | | | All found with "cppcheck --enable=unusedFunction".
* fileio: automatically add NULL sentinel to parse_env_file()Lennart Poettering2018-11-141-1/+1
| | | | Let's modernize things a bit.
* fileio: drop "newline" parameter for env file parsersLennart Poettering2018-11-141-1/+1
| | | | | | | Now that we don't (mis-)use the env file parser to parse kernel command lines there's no need anymore to override the used newline character set. Let's hence drop the argument and just "\n\r" always. This nicely simplifies our code.
* tree-wide: use typesafe_qsort()Yu Watanabe2018-09-191-1/+1
|
* tree-wide: remove Lennart's copyright linesLennart Poettering2018-06-141-3/+0
| | | | | | | | | | | These lines are generally out-of-date, incomplete and unnecessary. With SPDX and git repository much more accurate and fine grained information about licensing and authorship is available, hence let's drop the per-file copyright notice. Of course, removing copyright lines of others is problematic, hence this commit only removes my own lines and leaves all others untouched. It might be nicer if sooner or later those could go away too, making git the only and accurate source of authorship information.
* tree-wide: drop 'This file is part of systemd' blurbLennart Poettering2018-06-141-2/+0
| | | | | | | | | | | | | | | | This part of the copyright blurb stems from the GPL use recommendations: https://www.gnu.org/licenses/gpl-howto.en.html The concept appears to originate in times where version control was per file, instead of per tree, and was a way to glue the files together. Ultimately, we nowadays don't live in that world anymore, and this information is entirely useless anyway, as people are very welcome to copy these files into any projects they like, and they shouldn't have to change bits that are part of our copyright header for that. hence, let's just get rid of this old cruft, and shorten our codebase a bit.
* fileio: accept FILE* in addition to path in parse_env_file()Lennart Poettering2018-05-241-1/+1
| | | | | | | Most our other parsing functions do this, let's do this here too, internally we accept that anyway. Also, the closely related load_env_file() and load_env_file_pairs() also do this, so let's be systematic.
* tree-wide: drop license boilerplateZbigniew Jędrzejewski-Szmek2018-04-061-13/+0
| | | | | | | | | | Files which are installed as-is (any .service and other unit files, .conf files, .policy files, etc), are left as is. My assumption is that SPDX identifiers are not yet that well known, so it's better to retain the extended header to avoid any doubt. I also kept any copyright lines. We can probably remove them, but it'd nice to obtain explicit acks from all involved authors before doing that.
* tree-wide: use TAKE_PTR() and TAKE_FD() macrosYu Watanabe2018-04-051-4/+2
|
* macro: introduce TAKE_PTR() macroLennart Poettering2018-03-221-2/+1
| | | | | | | | | | | | | | | | This macro will read a pointer of any type, return it, and set the pointer to NULL. This is useful as an explicit concept of passing ownership of a memory area between pointers. This takes inspiration from Rust: https://doc.rust-lang.org/std/option/enum.Option.html#method.take and was suggested by Alan Jenkins (@sourcejedi). It drops ~160 lines of code from our codebase, which makes me like it. Also, I think it clarifies passing of ownership, and thus helps readability a bit (at least for the initiated who know the new macro)
* Add SPDX license identifiers to source files under the LGPLZbigniew Jędrzejewski-Szmek2017-11-191-0/+1
| | | | | This follows what the kernel is doing, c.f. https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=5fd54ace4721fc5ce2bb5aef6318fcf17f421460.
* bus: include sd-{bus,messages}.h the same as other systemd headersZbigniew Jędrzejewski-Szmek2017-04-211-2/+0
| | | | | | This is our own header, we should include use the local-include syntax ("" not <>), to make it clear we are including the one from the build tree. All other includes of files from src/systemd/ use this scheme.
* shared/cgroup-show: extract funtion to query unit cgroup pathZbigniew Jędrzejewski-Szmek2017-02-021-16/+31
| | | | …and use it where possible.
* cgtop: use common function to query cgroup rootZbigniew Jędrzejewski-Szmek2017-02-021-31/+45
| | | | | | | | | | | show_cgroup_get_root_and_warn is renamed to show_cgroup_get_path_and_warn because it now optionally allows querying a non-root path. This removes duplicated code and teaches cgtop to combine -M with a root prefix: $ systemd-cgtop -M myprecious /system.slice ...
* cgls: make function to query cgroup root publicZbigniew Jędrzejewski-Szmek2017-02-021-0/+55
| | | | No functional change.
* shared/cgroup-show: use (void)Zbigniew Jędrzejewski-Szmek2017-01-311-1/+1
| | | | CID #1368243.
* Rename formats-util.h to format-util.hZbigniew Jędrzejewski-Szmek2016-11-071-1/+1
| | | | | | We don't have plural in the name of any other -util files and this inconsistency trips me up every time I try to type this file name from memory. "formats-util" is even hard to pronounce.
* tree-wide: drop NULL sentinel from strjoinZbigniew Jędrzejewski-Szmek2016-10-231-1/+1
| | | | | | | | | | | | | This makes strjoin and strjoina more similar and avoids the useless final argument. spatch -I . -I ./src -I ./src/basic -I ./src/basic -I ./src/shared -I ./src/shared -I ./src/network -I ./src/locale -I ./src/login -I ./src/journal -I ./src/journal -I ./src/timedate -I ./src/timesync -I ./src/nspawn -I ./src/resolve -I ./src/resolve -I ./src/systemd -I ./src/core -I ./src/core -I ./src/libudev -I ./src/udev -I ./src/udev/net -I ./src/udev -I ./src/libsystemd/sd-bus -I ./src/libsystemd/sd-event -I ./src/libsystemd/sd-login -I ./src/libsystemd/sd-netlink -I ./src/libsystemd/sd-network -I ./src/libsystemd/sd-hwdb -I ./src/libsystemd/sd-device -I ./src/libsystemd/sd-id128 -I ./src/libsystemd-network --sp-file coccinelle/strjoin.cocci --in-place $(git ls-files src/*.c) git grep -e '\bstrjoin\b.*NULL' -l|xargs sed -i -r 's/strjoin\((.*), NULL\)/strjoin(\1)/' This might have missed a few cases (spatch has a really hard time dealing with _cleanup_ macros), but that's no big issue, they can always be fixed later.
* tree-wide: rename draw_special_char to special_glyphZbigniew Jędrzejewski-Szmek2016-05-091-5/+5
| | | | | | | | | That function doesn't draw anything on it's own, just returns a string, which sometimes is more than one character. Also remove "DRAW_" prefix from character names, TREE_* and ARROW and BLACK_CIRCLE are unambigous on their own, don't draw anything, and are always used as an argument to special_glyph(). Rename "DASH" to "MDASH", as there's more than one type of dash.
* shared: drop kernel_thread bool from cgroups show codeLennart Poettering2016-04-221-17/+19
| | | | | Make this an output flag instead, so that our function prototypes can lose one parameter
* core,systemctl: add bus API to retrieve processes of a unitLennart Poettering2016-04-221-19/+51
| | | | | | | | | | | | | | | This adds a new GetProcesses() bus call to the Unit object which returns an array consisting of all PIDs, their process names, as well as their full cgroup paths. This is then used by "systemctl status" to show the per-unit process tree. This has the benefit that the client-side no longer needs to access the cgroupfs directly to show the process tree of a unit. Instead, it now uses this new API, which means it also works if -H or -M are used correctly, as the information from the specific host is used, and not the one from the local system. Fixes: #2945
* tree-wide: remove Emacs lines from all filesDaniel Mack2016-02-101-2/+0
| | | | | This should be handled fine now by .dir-locals.el, so need to carry that stuff in every file.
* shared: include what we useThomas Hindoe Paaboel Andersen2015-12-061-1/+3
| | | | | The next step of a general cleanup of our includes. This one mostly adds missing includes but there are a few removals as well.
* util-lib: split out allocation calls into alloc-util.[ch]Lennart Poettering2015-10-271-0/+1
|
* util-lib: move more locale-related calls to locale-util.[ch]Lennart Poettering2015-10-271-0/+1
|
* util-lib: split out fd-related operations into fd-util.[ch]Lennart Poettering2015-10-251-1/+2
| | | | | There are more than enough to deserve their own .c file, hence move them over.
* util-lib: split our string related calls from util.[ch] into its own file ↵Lennart Poettering2015-10-241-6/+7
| | | | | | | | | | | | | | string-util.[ch] There are more than enough calls doing string manipulations to deserve its own files, hence do something about it. This patch also sorts the #include blocks of all files that needed to be updated, according to the sorting suggestions from CODING_STYLE. Since pretty much every file needs our string manipulation functions this effectively means that most files have sorted #include blocks now. Also touches a few unrelated include files.
* cgroup: drop "ignore_self" argument from cg_is_empty()Lennart Poettering2015-09-011-1/+1
| | | | | | | In all cases where the function (or cg_is_empty_recursive()) ignoring the calling process is actually wrong, as a process keeps a cgroup busy regardless if its the current one or another. Hence, let's simplify things and drop the "ignore_self" parameter.
* cgroup-show: unescape cgroups on presentationLennart Poettering2015-08-281-4/+2
| | | | | Let's unescape cgroups on presentation, so that we show literal unit names.
* shared: add terminal-util.[ch]Ronny Chevalier2015-04-111-0/+1
|
* shared: add process-util.[ch]Ronny Chevalier2015-04-101-0/+1
|
* shared: add formats-util.hRonny Chevalier2015-04-101-0/+1
|
* util: rework strappenda(), and rename it strjoina()Lennart Poettering2015-02-031-1/+1
| | | | | | After all it is now much more like strjoin() than strappend(). At the same time, add support for NULL sentinels, even if they are normally not necessary.
* cgroup-show: remove duplicated checkZbigniew Jędrzejewski-Szmek2015-01-231-3/+2
| | | | After 3637713a20 it is not necessary anymore.
* cgroup-show: don't hit assert, when the extra pids array is emptyLennart Poettering2015-01-221-1/+3
|
* shared/cgroup-show: simplify show_pid_array()Zbigniew Jędrzejewski-Szmek2015-01-221-36/+14
| | | | | | int[] should not be used as pid_t[], even if happens to be same thing. Also deduplicating in a quadratic loop right before sorting is unnecessary. Remove custom greedy_realloc implementation.
* delta: draw arrows with draw_special_char()Lennart Poettering2014-04-231-5/+7
| | | | | | | Let's unify generation of unicode chars at one place. Also, don't add an extra space into chars we print, except for the tree chars where this is really necessary.
* Get rid of our reimplementation of basenameZbigniew Jędrzejewski-Szmek2013-12-071-2/+2
| | | | | | The only problem is that libgen.h #defines basename to point to it's own broken implementation instead of the GNU one. This can be fixed by #undefining basename.