26 #ifndef VCSN_TOOLS_OUT_DISPLAY_HXX
27 # define VCSN_TOOLS_OUT_DISPLAY_HXX
30 # include <sys/types.h>
31 # include <sys/wait.h>
38 template <
class S,
class T>
40 out_display(
const AutomataBase<S>&,
42 const Element<S, T>& a,
43 const std::string& name,
45 const char *
const argv[],
46 void (*
function)(std::ostream& o,
47 const Element<S, T>& a,
48 const std::string& name))
55 pid_t child_pid = fork();
69 int old = dup(STDOUT_FILENO);
71 dup2(filedes[1], STDOUT_FILENO);
74 function(std::cout, a, name);
78 dup2(old, STDOUT_FILENO);
82 return bg or waitpid(child_pid, NULL, 0) == child_pid;
88 dup2(filedes[0], STDIN_FILENO);
94 execvp(argv[0], const_cast<char *const *>(argv));
95 std::cerr <<
"Failed to execute `" << argv[0] <<
"'." << std::endl;
104 #endif // ! VCSN_TOOLS_OUT_DISPLAY_HXX