summaryrefslogtreecommitdiff
path: root/src/basic/process-util.c
AgeCommit message (Collapse)Author
2016-06-21tree-wide: some work-arounds for gcc false positives regarding uninitialized ↵Lennart Poettering
variables
2016-06-16process-util: fix two bugs in get_process_cmdline() (#3555)Lennart Poettering
See: https://github.com/systemd/systemd/pull/3529#issuecomment-226421007
2016-06-14util-lib: rework get_process_cmdline() (#3529)Lennart Poettering
This reworks get_process_cmdline() quite substantially, fixing the following: - Fixes: https://github.com/systemd/systemd/pull/3512/commits/a4e3bf4d7ac2de51191ce136ee9361ba319e106c#r66837630 - The passed max_length is also applied to the "comm" name, if comm_fallback is set. - The right thing happens if max_length == 1 is specified - when the cmdline "foobar" is abbreviated to 6 characters the result is not "foobar" instead of "foo...". - trailing whitespace are removed before the ... suffix is appended. The 7 character abbreviation of "foo barz" is hence "foo..." instead of "foo ...". - leading whitespace are suppressed from the cmdline - a comprehensive test case is added
2016-06-12process-util: remove broken support for pid==0Zbigniew Jędrzejewski-Szmek
Our functions that query /proc/pid/ support using pid==0 to mean self. get_process_id also seemed to support that, but it was not implemented correctly: the result should be in *uid, not returned, and also it gave completely bogus result when called from get_process_gid(). But afaict, get_process_{uid,gid} were never called with pid==0, so it's not an actual bug. Remove the broken code to avoid confusion.
2016-06-12util-lib: drop trailing non-printable characters from cmdline (#3512)Max Prokhorov
If max_length is equal or greater than cmdline length all trailing non-printable characters are dropped. If max_length is 0 it should do the same. This should also fix cmdline truncation if the last character is not '\0'. Fixes #3469.
2016-05-29util-lib: Add sparc64 support for process creation (#3348)Michael Karcher
The current raw_clone function takes two arguments, the cloning flags and a pointer to the stack for the cloned child. The raw cloning without passing a "thread main" function does not make sense if a new stack is specified, as it returns in both the parent and the child, which will fail in the child as the stack is virgin. All uses of raw_clone indeed pass NULL for the stack pointer which indicates that both processes should share the stack address (so you better don't pass CLONE_VM). This commit refactors the code to not require the caller to pass the stack address, as NULL is the only sensible option. It also adds the magic code needed to make raw_clone work on sparc64, which does not return 0 in %o0 for the child, but indicates the child process by setting %o1 to non-zero. This refactoring is not plain aesthetic, because non-NULL stack addresses need to get mangled before being passed to the clone syscall (you have to apply STACK_BIAS), whereas NULL must not be mangled. Implementing the conditional mangling of the stack address would needlessly complicate the code. raw_clone is moved to a separete header, because the burden of including the assert machinery and sched.h shouldn't be applied to every user of missing_syscalls.h
2016-05-21core: set all log fds to -1 when freezing (#3314)Evgeny Vereshchagin
Fixes: -bash-4.3# echo core >/proc/sys/kernel/core_pattern -bash-4.3# kill -ABRT 1 -bash-4.3# kill -ABRT 1 [ 61.373922] systemd[1]: segfault at 7fff1d0a8f48 ip 00007fc9ca91b1c3 sp 00007fff1d0a8f50 error 6 in libc-2.23.so[7fc9ca8ce000+1c0000] [ 61.768017] Kernel panic - not syncing: Attempted to kill init! exitcode=0x0000008b [ 61.768017] ... Recursive ABRT and segfault: PID 1 - core TID 1: ... #153905 0x00005575fc3f829d log_dispatch #153906 0x00005575fc3f8aa3 log_assert #153907 0x00005575fc3f8ae9 log_assert_failed #153908 0x00005575fc3e7eb1 safe_close #153909 0x00005575fc3f6d5e log_close_journal #153910 0x00005575fc3f829d log_dispatch #153911 0x00005575fc3f85a1 log_internalv #153912 0x00005575fc3f86a1 log_internal #153913 0x00005575fc31c4c1 crash #153914 0x00007fb26f2cf3d0 __restore_rt #153915 0x00007fb26f2ced00 pause #153916 0x00005575fc403944 freeze #153917 0x00005575fc31bf7b freeze_or_reboot ...
2016-05-02util: rework sigkill_wait() to not require pid_t pointerLennart Poettering
Let's make sigkill_wait() take a normal pid_t, and add sigkill_waitp() that takes a pointer (which is useful for usage in _cleanup_), following the usual logic we have for this.
2016-04-22core,systemctl: add bus API to retrieve processes of a unitLennart Poettering
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
2016-02-22util-lib: simplify personality() string matchingLennart Poettering
2016-02-22util-lib: support various ppc archs in personality logicLennart Poettering
2016-02-22util-lib: use the architecture ids from architecture.h for personalitiesLennart Poettering
We have this ids, hence let's use them universally.
2016-02-19Use (void) to silenc coverity on proc title changesZbigniew Jędrzejewski-Szmek
This is a cosmetic best-effort thing anyway.
2016-01-26shutdown: complain if process excluded from killing spree runs of the same ↵Michal Sekletar
rootfs as PID1
2016-01-21core: add valgrind helper for daemon-reexecEvgeny Vereshchagin
Inspired by https://github.com/systemd/systemd/issues/2187#issuecomment-165587140
2015-12-01basic: re-sort includesThomas Hindoe Paaboel Andersen
My previous patch to only include what we use accidentially placed the added inlcudes in non-sorted order.
2015-11-30basic: include only what we useThomas Hindoe Paaboel Andersen
This is a cleaned up result of running iwyu but without forward declarations on src/basic.
2015-10-27process-util: move a couple of process-related calls overLennart Poettering
2015-10-27process-util: make some minor corrections to PID live detectionLennart Poettering
2015-10-27process-util: rename get_parent_of_pid() → get_process_ppid()Lennart Poettering
In order to match the other get_process_xyz() calls.
2015-10-27process-util: actually move rename_process() overLennart Poettering
The prototype was moved long ago, actually move the definition over now, too.
2015-10-27util-lib: split out allocation calls into alloc-util.[ch]Lennart Poettering
2015-10-27util-lib: move is_main_thread() to process-util.[ch]Lennart Poettering
2015-10-27util-lib: move a number of fs operations into fs-util.[ch]Lennart Poettering
2015-10-26process-util: move more process related calls to process-util.[ch]Lennart Poettering
2015-10-26util-lib: split out user/group/uid/gid calls into user-util.[ch]Lennart Poettering
2015-10-25util-lib: split out fd-related operations into fd-util.[ch]Lennart Poettering
There are more than enough to deserve their own .c file, hence move them over.
2015-10-24util-lib: split our string related calls from util.[ch] into its own file ↵Lennart Poettering
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.
2015-10-24util: split out escaping code into escape.[ch]Lennart Poettering
This really deserves its own file, given how much code this is now.
2015-09-30fileio: make get_status_field() more genericAaro Koskinen
All users of get_status_field() expect the field pattern to occur in the beginning of a line, and the delimiter is ':'. Hardcode this into the function, and also skip any whitespace before ':' to support fields in files like /proc/cpuinfo. Add support for returning the full field value (currently stops on first whitespace). Rename the function so it's easier to ensure all callers switch to new semantics.
2015-08-31process-util: trivial optimizationLennart Poettering
2015-07-23process: an empty environment block should be returned as suchLennart Poettering
An empty env block is completely valid, hence return it as such, and don't turn it into an error.
2015-07-23process: return ESRCH when a PID is not valid anymoreLennart Poettering
so far, when we read something from /proc/$PID we would pass on the ENOENT from the kernel as error, if the process was missing. With this change we systematically convert this to ESRCH, which is the more appropriate error code, and what all the other glibc/syscalls like kill() use. All code that calls these functions should be fine with this change. In fact, one invocation of get_process_exe() in bus-creds.c already assumed ESRCH would be returned if a process is missing, and this assumption is now validated after the change.
2015-07-06get_process_environ: exit early when there is nothing to readKay Sievers
2015-06-11build-sys: split internal basic/ library from shared/Kay Sievers
basic/ can be used by everything cannot use anything outside of basic/ libsystemd/ can use basic/ cannot use shared/ shared/ can use libsystemd/