Skip to content

Commit 395d046

Browse files
committed
Wait for procfs.
Commit systemd/systemd@f917813 in advertently caused bootchart to exit with error upon any issue logging a sample. However, the code was specifically written to allow the system to bring up `procfs` and should keep running in the absence of it.
1 parent 9b004a7 commit 395d046

1 file changed

Lines changed: 9 additions & 3 deletions

File tree

src/bootchart.c

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -326,6 +326,7 @@ int main(int argc, char *argv[]) {
326326
struct sigaction sig = {
327327
.sa_handler = signal_handler,
328328
};
329+
bool has_procfs = false;
329330

330331
parse_conf();
331332

@@ -387,6 +388,8 @@ int main(int argc, char *argv[]) {
387388
return EXIT_FAILURE;
388389
}
389390

391+
has_procfs = access("/proc/vmstat", F_OK) == 0;
392+
390393
LIST_HEAD_INIT(head);
391394

392395
/* main program loop */
@@ -413,12 +416,15 @@ int main(int argc, char *argv[]) {
413416
parse_env_file("/usr/lib/os-release", NEWLINE, "PRETTY_NAME", &build, NULL);
414417
}
415418

416-
if (proc)
419+
if (!has_procfs) {
420+
/* wait for /proc to become available, discarding samples */
421+
has_procfs = access("/proc/vmstat", F_OK) == 0;
422+
} else if (proc) {
417423
rewinddir(proc);
418-
else
424+
} else {
419425
proc = opendir("/proc");
426+
}
420427

421-
/* wait for /proc to become available, discarding samples */
422428
if (proc) {
423429
r = log_sample(proc, samples, ps_first, &sampledata, &pscount, &n_cpus);
424430
if (r < 0)

0 commit comments

Comments
 (0)