From 59a1fb96dbef9a91638d13c4eb0f93270c35535f Mon Sep 17 00:00:00 2001 From: Marek Marczykowski Date: Fri, 20 Jul 2012 16:41:26 +0200 Subject: [PATCH] dom0/meminfo-writer: fork into background after first info sent to qmemman (#635) --- dom0/init.d/qubes_core | 2 +- misc/meminfo-writer.c | 11 +++++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/dom0/init.d/qubes_core b/dom0/init.d/qubes_core index c932b19b..3a6b4ed9 100755 --- a/dom0/init.d/qubes_core +++ b/dom0/init.d/qubes_core @@ -33,7 +33,7 @@ start() /usr/lib/qubes/qmemman_daemon.py MEM_CHANGE_THRESHOLD_KB=30000 MEMINFO_DELAY_USEC=100000 - /usr/lib/qubes/meminfo-writer $MEM_CHANGE_THRESHOLD_KB $MEMINFO_DELAY_USEC & + /usr/lib/qubes/meminfo-writer $MEM_CHANGE_THRESHOLD_KB $MEMINFO_DELAY_USEC /usr/lib/qubes/block_cleaner_daemon.py > /var/log/qubes/block_cleaner.log 2>&1 & diff --git a/misc/meminfo-writer.c b/misc/meminfo-writer.c index c9e10594..f3563b14 100644 --- a/misc/meminfo-writer.c +++ b/misc/meminfo-writer.c @@ -154,6 +154,17 @@ int main(int argc, char **argv) perror("xs_domain_open"); exit(1); } + if (argc == 3) { + /* if not waiting for signal, fork after first info written to xenstore */ + n = pread(fd, buf, sizeof(buf), 0); + buf[n] = 0; + meminfo_data = parse(buf); + if (meminfo_data) + send_to_qmemman(xs, meminfo_data); + if (fork() > 0) + exit(0); + } + for (;;) { n = pread(fd, buf, sizeof(buf), 0); buf[n] = 0;