[C++] Re-generate ninja file when a file is added/removed

With this change, we store the results of file list related
commands in .kati_stamp. If one of them has been changed,
we re-generate ninja file.

Currently, this check is slow. We need to check the timestamp
of directories first like what we are doing for $(wildcard).
diff --git a/fileutil.cc b/fileutil.cc
index 86d66e0..d2035f3 100644
--- a/fileutil.cc
+++ b/fileutil.cc
@@ -17,6 +17,7 @@
 #include "fileutil.h"
 
 #include <errno.h>
+#include <fcntl.h>
 #include <glob.h>
 #include <limits.h>
 #include <sys/stat.h>
@@ -53,7 +54,8 @@
 #endif
 }
 
-int RunCommand(const string& shell, const string& cmd, bool redirect_stderr,
+int RunCommand(const string& shell, const string& cmd,
+               RedirectStderr redirect_stderr,
                string* s) {
   int pipefd[2];
   if (pipe(pipefd) != 0)
@@ -86,9 +88,14 @@
     return status;
   } else {
     close(pipefd[0]);
-    if (redirect_stderr) {
+    if (redirect_stderr == RedirectStderr::STDOUT) {
       if (dup2(pipefd[1], 2) < 0)
         PERROR("dup2 failed");
+    } else if (redirect_stderr == RedirectStderr::DEV_NULL) {
+      int fd = open("/dev/null", O_WRONLY);
+      if (dup2(fd, 2) < 0)
+        PERROR("dup2 failed");
+      close(fd);
     }
     if (dup2(pipefd[1], 1) < 0)
       PERROR("dup2 failed");