Skip to content

Commit

Permalink
Wait for procfs.
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
sofar committed Apr 5, 2017
1 parent 9b004a7 commit 395d046
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions src/bootchart.c
Original file line number Diff line number Diff line change
Expand Up @@ -326,6 +326,7 @@ int main(int argc, char *argv[]) {
struct sigaction sig = {
.sa_handler = signal_handler,
};
bool has_procfs = false;

parse_conf();

Expand Down Expand Up @@ -387,6 +388,8 @@ int main(int argc, char *argv[]) {
return EXIT_FAILURE;
}

has_procfs = access("/proc/vmstat", F_OK) == 0;

LIST_HEAD_INIT(head);

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

if (proc)
if (!has_procfs) {
/* wait for /proc to become available, discarding samples */
has_procfs = access("/proc/vmstat", F_OK) == 0;
} else if (proc) {
rewinddir(proc);
else
} else {
proc = opendir("/proc");
}

/* wait for /proc to become available, discarding samples */
if (proc) {
r = log_sample(proc, samples, ps_first, &sampledata, &pscount, &n_cpus);
if (r < 0)
Expand Down

0 comments on commit 395d046

Please sign in to comment.