68 lines
1.7 KiB
Diff
68 lines
1.7 KiB
Diff
|
|
diff --git a/src/proc_fuse.c b/src/proc_fuse.c
|
||
|
|
index 334f6ea..3ceba73 100644
|
||
|
|
--- a/src/proc_fuse.c
|
||
|
|
+++ b/src/proc_fuse.c
|
||
|
|
@@ -51,6 +51,26 @@
|
||
|
|
#include "proc_cpuview.h"
|
||
|
|
#include "utils.h"
|
||
|
|
|
||
|
|
+static pthread_mutex_t container_dev_mutex = PTHREAD_MUTEX_INITIALIZER;
|
||
|
|
+
|
||
|
|
+static void lock_mutex(pthread_mutex_t *l)
|
||
|
|
+{
|
||
|
|
+ int ret;
|
||
|
|
+
|
||
|
|
+ ret = pthread_mutex_lock(l);
|
||
|
|
+ if (ret)
|
||
|
|
+ log_exit("%s - returned %d\n", strerror(ret), ret);
|
||
|
|
+}
|
||
|
|
+
|
||
|
|
+static void unlock_mutex(pthread_mutex_t *l)
|
||
|
|
+{
|
||
|
|
+ int ret;
|
||
|
|
+
|
||
|
|
+ ret = pthread_mutex_unlock(l);
|
||
|
|
+ if (ret)
|
||
|
|
+ log_exit("%s - returned %d\n", strerror(ret), ret);
|
||
|
|
+}
|
||
|
|
+
|
||
|
|
struct memory_stat {
|
||
|
|
uint64_t hierarchical_memory_limit;
|
||
|
|
uint64_t hierarchical_memsw_limit;
|
||
|
|
@@ -418,6 +438,16 @@ struct devinfo* container_dev_read(pid_t pid) {
|
||
|
|
return head;
|
||
|
|
}
|
||
|
|
if (child_pid == 0) {
|
||
|
|
+ /* Disallow signal reception in child process */
|
||
|
|
+ sigset_t oldset;
|
||
|
|
+ sigset_t newset;
|
||
|
|
+ sigemptyset(&newset);
|
||
|
|
+ sigaddset(&newset, SIGTERM);
|
||
|
|
+ sigaddset(&newset, SIGINT);
|
||
|
|
+ sigaddset(&newset, SIGHUP);
|
||
|
|
+ sigaddset(&newset, SIGQUIT);
|
||
|
|
+ sigprocmask(SIG_BLOCK,&newset,&oldset);
|
||
|
|
+
|
||
|
|
close(mypipe[0]);
|
||
|
|
stream = fdopen(mypipe[1], "w");
|
||
|
|
if (stream == NULL) {
|
||
|
|
@@ -464,6 +494,8 @@ child_out:
|
||
|
|
lxcfs_error("Error opening pipe for reading: %s\n", strerror(errno));
|
||
|
|
goto err;
|
||
|
|
}
|
||
|
|
+ wait_for_pid(child_pid);
|
||
|
|
+ child_pid = 0;
|
||
|
|
while (fscanf(stream, "%100s%d", dev_name, &dev_num) == 2) {
|
||
|
|
if (dev_num == 0) {
|
||
|
|
break;
|
||
|
|
@@ -590,7 +622,9 @@ static int proc_diskstats_read(char *buf, size_t size, off_t offset,
|
||
|
|
if (!f)
|
||
|
|
return 0;
|
||
|
|
|
||
|
|
+ lock_mutex(&container_dev_mutex);
|
||
|
|
container_devinfo = container_dev_read(initpid);
|
||
|
|
+ unlock_mutex(&container_dev_mutex);
|
||
|
|
|
||
|
|
while (getline(&line, &linelen, f) != -1) {
|
||
|
|
ssize_t l;
|