| 170 | } |
| 171 | |
| 172 | int shell_exec(const char *cmd) |
| 173 | { |
| 174 | char *shell = getenv("RSYNC_SHELL"); |
| 175 | int status; |
| 176 | pid_t pid; |
| 177 | |
| 178 | if (!shell) |
| 179 | return system(cmd); |
| 180 | |
| 181 | if ((pid = fork()) < 0) |
| 182 | return -1; |
| 183 | |
| 184 | if (pid == 0) { |
| 185 | execlp(shell, shell, "-c", cmd, NULL); |
| 186 | _exit(1); |
| 187 | } |
| 188 | |
| 189 | int ret = wait_process(pid, &status, 0); |
| 190 | return ret < 0 ? -1 : status; |
| 191 | } |
| 192 | |
| 193 | /* Wait for a process to exit, calling io_flush while waiting. */ |
| 194 | static void wait_process_with_flush(pid_t pid, int *exit_code_ptr) |
no test coverage detected