process-util.h revision ceee6d3a44a81bcf42b21b777302a226422b11a1
f579559b3a14c1f1ef96c372e7626c4733e6ef7dTom Gundersen This file is part of systemd.
f579559b3a14c1f1ef96c372e7626c4733e6ef7dTom Gundersen Copyright 2010 Lennart Poettering
f579559b3a14c1f1ef96c372e7626c4733e6ef7dTom Gundersen systemd is free software; you can redistribute it and/or modify it
f579559b3a14c1f1ef96c372e7626c4733e6ef7dTom Gundersen under the terms of the GNU Lesser General Public License as published by
f579559b3a14c1f1ef96c372e7626c4733e6ef7dTom Gundersen the Free Software Foundation; either version 2.1 of the License, or
f579559b3a14c1f1ef96c372e7626c4733e6ef7dTom Gundersen (at your option) any later version.
f579559b3a14c1f1ef96c372e7626c4733e6ef7dTom Gundersen systemd is distributed in the hope that it will be useful, but
f579559b3a14c1f1ef96c372e7626c4733e6ef7dTom Gundersen WITHOUT ANY WARRANTY; without even the implied warranty of
f579559b3a14c1f1ef96c372e7626c4733e6ef7dTom Gundersen MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
f579559b3a14c1f1ef96c372e7626c4733e6ef7dTom Gundersen Lesser General Public License for more details.
f579559b3a14c1f1ef96c372e7626c4733e6ef7dTom Gundersen You should have received a copy of the GNU Lesser General Public License
f579559b3a14c1f1ef96c372e7626c4733e6ef7dTom Gundersen along with systemd; If not, see <http://www.gnu.org/licenses/>.
09bee74d7a5f266b175baa19892fa84a9da51d7fTom Gundersen const char *_r_; \
09bee74d7a5f266b175baa19892fa84a9da51d7fTom Gundersen if (_pid_ == 0) { \
09bee74d7a5f266b175baa19892fa84a9da51d7fTom Gundersen _r_ = alloca(strlen("/proc/") + DECIMAL_STR_MAX(pid_t) + 1 + sizeof(field)); \
09bee74d7a5f266b175baa19892fa84a9da51d7fTom Gundersen sprintf((char*) _r_, "/proc/"PID_FMT"/" field, _pid_); \
a2ba62c719224a4b47751623ca5e8b0333f49721Lennart Poetteringint get_process_comm(pid_t pid, char **name);
09bee74d7a5f266b175baa19892fa84a9da51d7fTom Gundersenint get_process_cmdline(pid_t pid, size_t max_length, bool comm_fallback, char **line);
09bee74d7a5f266b175baa19892fa84a9da51d7fTom Gundersenint get_process_capeff(pid_t pid, char **capeff);
a2ba62c719224a4b47751623ca5e8b0333f49721Lennart Poetteringint get_process_cwd(pid_t pid, char **cwd);
09bee74d7a5f266b175baa19892fa84a9da51d7fTom Gundersenint get_process_environ(pid_t pid, char **environ);
09bee74d7a5f266b175baa19892fa84a9da51d7fTom Gundersenint wait_for_terminate(pid_t pid, siginfo_t *status);
09bee74d7a5f266b175baa19892fa84a9da51d7fTom Gundersenint wait_for_terminate_and_warn(const char *name, pid_t pid, bool check_exit_code);
e1ea665edac17d75fce01b72dadfa3211b60df2cEugene Yakubovich#define _cleanup_sigkill_wait_ _cleanup_(sigkill_wait)
e1ea665edac17d75fce01b72dadfa3211b60df2cEugene Yakubovichpid_t get_parent_of_pid(pid_t pid, pid_t *ppid);
e1ea665edac17d75fce01b72dadfa3211b60df2cEugene Yakubovichint getenv_for_pid(pid_t pid, const char *field, char **_value);
e1ea665edac17d75fce01b72dadfa3211b60df2cEugene Yakubovich#define PTR_TO_PID(p) ((pid_t) ((uintptr_t) p))
e1ea665edac17d75fce01b72dadfa3211b60df2cEugene Yakubovich#define PID_TO_PTR(p) ((void*) ((uintptr_t) p))