• Home
  • History
  • Annotate
  • Raw
  • Download
  • only in /netgear-R7000-V1.0.7.12_1.2.5/components/opensource/linux/linux-2.6.36/tools/perf/util/

Lines Matching refs:cmd

18 int start_command(struct child_process *cmd)
28 need_in = !cmd->no_stdin && cmd->in < 0;
31 if (cmd->out > 0)
32 close(cmd->out);
35 cmd->in = fdin[1];
38 need_out = !cmd->no_stdout
39 && !cmd->stdout_to_stderr
40 && cmd->out < 0;
45 else if (cmd->in)
46 close(cmd->in);
49 cmd->out = fdout[0];
52 need_err = !cmd->no_stderr && cmd->err < 0;
57 else if (cmd->in)
58 close(cmd->in);
61 else if (cmd->out)
62 close(cmd->out);
65 cmd->err = fderr[0];
69 cmd->pid = fork();
70 if (!cmd->pid) {
71 if (cmd->no_stdin)
76 } else if (cmd->in) {
77 dup2(cmd->in, 0);
78 close(cmd->in);
81 if (cmd->no_stderr)
88 if (cmd->no_stdout)
90 else if (cmd->stdout_to_stderr)
95 } else if (cmd->out > 1) {
96 dup2(cmd->out, 1);
97 close(cmd->out);
100 if (cmd->dir && chdir(cmd->dir))
101 die("exec %s: cd to %s failed (%s)", cmd->argv[0],
102 cmd->dir, strerror(errno));
103 if (cmd->env) {
104 for (; *cmd->env; cmd->env++) {
105 if (strchr(*cmd->env, '='))
106 putenv((char*)*cmd->env);
108 unsetenv(*cmd->env);
111 if (cmd->preexec_cb)
112 cmd->preexec_cb();
113 if (cmd->perf_cmd) {
114 execv_perf_cmd(cmd->argv);
116 execvp(cmd->argv[0], (char *const*) cmd->argv);
121 if (cmd->pid < 0) {
125 else if (cmd->in)
126 close(cmd->in);
129 else if (cmd->out)
130 close(cmd->out);
140 else if (cmd->in)
141 close(cmd->in);
145 else if (cmd->out)
146 close(cmd->out);
185 int finish_command(struct child_process *cmd)
187 return wait_or_whine(cmd->pid);
190 int run_command(struct child_process *cmd)
192 int code = start_command(cmd);
195 return finish_command(cmd);
198 static void prepare_run_command_v_opt(struct child_process *cmd,
202 memset(cmd, 0, sizeof(*cmd));
203 cmd->argv = argv;
204 cmd->no_stdin = opt & RUN_COMMAND_NO_STDIN ? 1 : 0;
205 cmd->perf_cmd = opt & RUN_PERF_CMD ? 1 : 0;
206 cmd->stdout_to_stderr = opt & RUN_COMMAND_STDOUT_TO_STDERR ? 1 : 0;
211 struct child_process cmd;
212 prepare_run_command_v_opt(&cmd, argv, opt);
213 return run_command(&cmd);