[make-initrd] [PATCH v1 09/11] feature/procacct: Wait until procacct is initialized
Alexey Gladkov
gladkov.alexey at gmail.com
Thu Jun 15 20:59:18 MSK 2023
Signed-off-by: Alexey Gladkov <gladkov.alexey at gmail.com>
---
data/etc/rc.d/rc.sysinit | 3 +++
features/debug-procacct/src/procacct.c | 12 ++++++------
2 files changed, 9 insertions(+), 6 deletions(-)
diff --git a/data/etc/rc.d/rc.sysinit b/data/etc/rc.d/rc.sysinit
index de63bfa5..bdc3c907 100755
--- a/data/etc/rc.d/rc.sysinit
+++ b/data/etc/rc.d/rc.sysinit
@@ -43,6 +43,9 @@ fi
if [ -n "$have_acct" ]; then
mount -n -t sysfs sysfs /sys
/bin/procacct -o /tmp/procacct.stats 2>/tmp/procacct.err &
+ while [ ! -f /tmp/procacct.stats ]; do
+ sleep 0.1
+ done
fi
# Alt-Uparrow
diff --git a/features/debug-procacct/src/procacct.c b/features/debug-procacct/src/procacct.c
index 51c81734..bbee9ef7 100644
--- a/features/debug-procacct/src/procacct.c
+++ b/features/debug-procacct/src/procacct.c
@@ -568,12 +568,6 @@ int main(int argc, char *argv[])
}
}
- if (write_file) {
- fd_out = open(logfile, O_WRONLY | O_CREAT | O_TRUNC | O_SYNC, 0644);
- if (fd_out < 0)
- rd_fatal("cannot open output file: %s: %m", logfile);
- }
-
current_pid = getpid();
setup_netlink_fd(&fd_handler_list[FD_NETLINK]);
@@ -588,6 +582,12 @@ int main(int argc, char *argv[])
rd_fatal("unable to prepare file descriptor");
}
+ if (write_file) {
+ fd_out = open(logfile, O_WRONLY | O_CREAT | O_TRUNC | O_SYNC, 0644);
+ if (fd_out < 0)
+ rd_fatal("cannot open output file: %s: %m", logfile);
+ }
+
while (1) {
struct epoll_event ev[EV_MAX];
int fdcount;
--
2.33.8
More information about the Make-initrd
mailing list