From 6b6ab3b0ea7d2c0a75222bff2d2d42712e021e23 Mon Sep 17 00:00:00 2001
From: Ludovic Pouzenc <ludovic@pouzenc.fr>
Date: Sun, 2 Dec 2018 21:24:31 +0100
Subject: Improve comments

---
 pidu | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)

diff --git a/pidu b/pidu
index 2928e61..52ce2f2 100755
--- a/pidu
+++ b/pidu
@@ -4,7 +4,7 @@ from multiprocessing import Process, JoinableQueue, Queue, cpu_count
 
 # Forked process main proc
 def proc_du(q_in,counters_count, q_out):
-    # count size in local process memory
+    # Sum up all files' 512-byte blocks allocated
     local_counters = [0] * counters_count
     # consume messages from q_in until special 'done' message
     while True:
@@ -14,7 +14,6 @@ def proc_du(q_in,counters_count, q_out):
         try:
             for it in os.scandir(path):
                 # Sum up file or folder physicial size (in blocks) to local_counters
-                # Note : this is --apparent-size mode of du, not default mode
                 local_counters[counter_indice] += it.stat(follow_symlinks=False).st_blocks
                 # Put more work on queue (could be taken by an other process)
                 if it.is_dir(follow_symlinks=False):
@@ -29,6 +28,12 @@ def proc_du(q_in,counters_count, q_out):
     # After receiving special 'done' message, put results back into q_out
     q_out.put(local_counters)
 
+# Remarks on stat().st_blocks :
+# - may not be available on all systems
+# - are blocks of DEV_BSIZE bytes in C API
+# - turns to be 512 on Linux.
+# - https://docs.python.org/3/library/os.html#os.DirEntry.stat
+
 def main(args):
     q_in = JoinableQueue()
     q_out = Queue()
@@ -60,7 +65,7 @@ def main(args):
     except KeyboardInterrupt:
         pass
     finally:
-        # Forcibly kill all processes (should not be usefull in normal conditions)
+        # Forcibly kill all processes (should not be useful in normal conditions)
         list(map(lambda p: p.terminate(), process_list))
 
 def check_positive(value):
-- 
cgit v1.2.3