| 125 | |
| 126 | static void child_run(Fixture *f) __attribute__((noreturn)); |
| 127 | static void child_run(Fixture *f) { |
| 128 | ChildReceipt receipt = {0}; |
| 129 | bool ok = close_fd(&f->ack[0]); |
| 130 | if (!close_fd(&f->gate[1])) |
| 131 | ok = false; |
| 132 | if (getrlimit(RLIMIT_NOFILE, &receipt.observed) != 0) |
| 133 | ok = false; |
| 134 | errno = 0; |
| 135 | int fd = open(f->control, O_RDONLY); |
| 136 | receipt.control_errno = fd < 0 ? errno : 0; |
| 137 | if (fd >= 0 && close(fd) != 0) |
| 138 | ok = false; |
| 139 | if (restricted_requested && setrlimit(RLIMIT_NOFILE, &f->saved) != 0) |
| 140 | ok = false; |
| 141 | if (getrlimit(RLIMIT_NOFILE, &receipt.restored) != 0 || |
| 142 | !same_limit(&f->saved, &receipt.restored)) |
| 143 | ok = false; |
| 144 | if (receipt.observed.rlim_max != f->saved.rlim_max || |
| 145 | receipt.observed.rlim_cur != (restricted_requested ? 0 : f->saved.rlim_cur) || |
| 146 | receipt.control_errno != (restricted_requested ? EMFILE : 0)) |
| 147 | ok = false; |
| 148 | receipt.valid = ok; |
| 149 | bool sent = transfer(f->ack[1], &receipt, sizeof(receipt), true); |
| 150 | if (!sent || !ok) |
| 151 | _exit(90); |
| 152 | char release = 0; |
| 153 | if (!transfer(f->gate[0], &release, 1, false) || release != 'G') |
| 154 | _exit(91); |
| 155 | if (!close_fd(&f->ack[1]) || !close_fd(&f->gate[0])) |
| 156 | _exit(92); |
| 157 | cbm_cov_parent_failure_child_count(); |
| 158 | _exit(0); |
| 159 | } |
| 160 | |
| 161 | static int marker_present(const Fixture *f) { |
| 162 | struct stat info; |
no test coverage detected