fix show command for macos
authorN. Engelhardt <nak@symbioticeda.com>
Mon, 23 Sep 2019 15:25:30 +0000 (17:25 +0200)
committerN. Engelhardt <nak@symbioticeda.com>
Mon, 23 Sep 2019 15:47:05 +0000 (17:47 +0200)
passes/cmds/show.cc

index 2e9fc72af18bd6cebc92444558cddf7d35881c06..a3e969ef17693800768645757be9d94f80d087ad 100644 (file)
 #  include <dirent.h>
 #endif
 
+#ifdef __APPLE__
+#  include <unistd.h>
+#endif
+
 #ifdef YOSYS_ENABLE_READLINE
 #  include <readline/readline.h>
 #endif
@@ -866,7 +870,11 @@ struct ShowPass : public Pass {
                                log_cmd_error("Shell command failed!\n");
                } else
                if (format.empty()) {
+                       #ifdef __APPLE__
+                       std::string cmd = stringf("ps -fu %d | grep -q '[ ]%s' || xdot '%s' &", getuid(), dot_file.c_str(), dot_file.c_str());
+                       #else
                        std::string cmd = stringf("{ test -f '%s.pid' && fuser -s '%s.pid'; } || ( echo $$ >&3; exec xdot '%s'; ) 3> '%s.pid' &", dot_file.c_str(), dot_file.c_str(), dot_file.c_str(), dot_file.c_str());
+                       #endif
                        log("Exec: %s\n", cmd.c_str());
                        if (run_command(cmd) != 0)
                                log_cmd_error("Shell command failed!\n");