fixed lots of not-thread-safe things

Most of the things I fixed here were using libc functions that are
fundamentally not thread-safe.
diff --git a/aos/common/util/run_command_test.cc b/aos/common/util/run_command_test.cc
new file mode 100644
index 0000000..b440e47
--- /dev/null
+++ b/aos/common/util/run_command_test.cc
@@ -0,0 +1,39 @@
+#include "aos/common/util/run_command.h"
+
+#include "gtest/gtest.h"
+
+namespace aos {
+namespace util {
+namespace testing {
+
+TEST(RunCommandTest, True) {
+  int result = RunCommand("true");
+  ASSERT_NE(-1, result);
+  ASSERT_TRUE(WIFEXITED(result));
+  EXPECT_EQ(0, WEXITSTATUS(result));
+}
+
+TEST(RunCommandTest, False) {
+  int result = RunCommand("false");
+  ASSERT_NE(-1, result);
+  ASSERT_TRUE(WIFEXITED(result));
+  EXPECT_EQ(1, WEXITSTATUS(result));
+}
+
+TEST(RunCommandTest, CommandNotFound) {
+  int result = RunCommand("ajflkjasdlfa");
+  ASSERT_NE(-1, result);
+  ASSERT_TRUE(WIFEXITED(result));
+  EXPECT_EQ(127, WEXITSTATUS(result));
+}
+
+TEST(RunCommandTest, KilledBySignal) {
+  int result = RunCommand("kill -QUIT $$");
+  ASSERT_NE(-1, result);
+  ASSERT_TRUE(WIFSIGNALED(result));
+  EXPECT_EQ(SIGQUIT, WTERMSIG(result));
+}
+
+}  // namespace testing
+}  // namespace util
+}  // namespace aos