MCPcopy Create free account
hub / github.com/RsyncProject/rsync / remember_children

Function remember_children

main.c:1643–1667  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1641#endif
1642
1643void remember_children(UNUSED(int val))
1644{
1645#ifdef WNOHANG
1646 int cnt, status;
1647 pid_t pid;
1648 /* An empty waitpid() loop was put here by Tridge and we could never
1649 * get him to explain why he put it in, so rather than taking it
1650 * out we're instead saving the child exit statuses for later use.
1651 * The waitpid() loop presumably eliminates all possibility of leaving
1652 * zombie children, maybe that's why he did it. */
1653 while ((pid = waitpid(-1, &status, WNOHANG)) > 0) {
1654 /* save the child's exit status */
1655 for (cnt = 0; cnt < MAXCHILDPROCS; cnt++) {
1656 if (pid_stat_table[cnt].pid == 0) {
1657 pid_stat_table[cnt].pid = pid;
1658 pid_stat_table[cnt].status = status;
1659 break;
1660 }
1661 }
1662 }
1663#endif
1664#ifndef HAVE_SIGACTION
1665 signal(SIGCHLD, remember_children);
1666#endif
1667}
1668
1669/**
1670 * This routine catches signals and tries to send them to gdb.

Callers

nothing calls this directly

Calls 1

waitpidFunction · 0.85

Tested by

no test coverage detected