MCPcopy Index your code
hub / github.com/RsyncProject/rsync / wait_process

Function wait_process

main.c:148–170  ·  view source on GitHub ↗

Works like waitpid(), but if we already harvested the child pid in our * remember_children(), we succeed instead of returning an error. */

Source from the content-addressed store, hash-verified

146/* Works like waitpid(), but if we already harvested the child pid in our
147 * remember_children(), we succeed instead of returning an error. */
148pid_t wait_process(pid_t pid, int *status_ptr, int flags)
149{
150 pid_t waited_pid;
151
152 do {
153 waited_pid = waitpid(pid, status_ptr, flags);
154 } while (waited_pid == -1 && errno == EINTR);
155
156 if (waited_pid == -1 && errno == ECHILD) {
157 /* Status of requested child no longer available: check to
158 * see if it was processed by remember_children(). */
159 int cnt;
160 for (cnt = 0; cnt < MAXCHILDPROCS; cnt++) {
161 if (pid == pid_stat_table[cnt].pid) {
162 *status_ptr = pid_stat_table[cnt].status;
163 pid_stat_table[cnt].pid = 0;
164 return pid;
165 }
166 }
167 }
168
169 return waited_pid;
170}
171
172int shell_exec(const char *cmd)
173{

Callers 5

_exit_cleanupFunction · 0.85
shell_execFunction · 0.85
wait_process_with_flushFunction · 0.85
finish_pre_execFunction · 0.85
rsync_moduleFunction · 0.85

Calls 1

waitpidFunction · 0.85

Tested by

no test coverage detected