static int manager_dispatch_sigchld(Manager *m) {
assert(m);
- log_debug("dispatching SIGCHLD");
-
for (;;) {
siginfo_t si;
Unit *u;
switch (sfsi.ssi_signo) {
- case SIGCHLD:
+ case SIGCHLD: {
+ char *name = NULL;
+
+ get_process_name(sfsi.ssi_pid, &name);
+ log_debug("Got SIGCHLD for process %llu (%s)", (unsigned long long) sfsi.ssi_pid, strna(name));
+ free(name);
+
sigchld = true;
break;
+ }
case SIGINT:
case SIGTERM:
return r;
}
+char *truncate_nl(char *s) {
+ assert(s);
+
+ s[strcspn(s, NEWLINE)] = 0;
+ return s;
+}
+
+int get_process_name(pid_t pid, char **name) {
+ char *p;
+ int r;
+
+ assert(pid >= 1);
+ assert(name);
+
+ if (asprintf(&p, "/proc/%llu/comm", (unsigned long long) pid) < 0)
+ return -ENOMEM;
+
+ r = read_one_line_file(p, name);
+ free(p);
+
+ if (r < 0)
+ return r;
+
+ truncate_nl(*name);
+ return 0;
+}
+
char *strappend(const char *s, const char *suffix) {
size_t a, b;
char *r;
/* What is interpreted as whitespace? */
#define WHITESPACE " \t\n\r"
+#define NEWLINE "\n\r"
usec_t now(clockid_t clock);
char *strstrip(char *s);
char *delete_chars(char *s, const char *bad);
+char *truncate_nl(char *s);
char *file_in_same_dir(const char *path, const char *filename);
int mkdir_parents(const char *path, mode_t mode);
+int get_process_name(pid_t pid, char **name);
+
char hexchar(int x);
int unhexchar(char c);
char octchar(int x);