this repo has no description
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Don't set CLOEXEC on "created" descriptors in posix_spawn

Instead of using the `inherit` action, LLDB uses `dup2` with both FDs being the same number. This is supported by XNU, so we have to support it as well. The solution is to see if each descriptor we want to set CLOEXEC on is present in the file actions list. If it is, then we *don't* set CLOEXEC on it.

Also, implement octal formatting in `__simple_vsnprintf`.

+59
+36
src/kernel/emulation/linux/process/posix_spawn.c
··· 125 125 continue; 126 126 } 127 127 128 + if (desc && desc->factp) { 129 + // if this FD is one that we're creating, don't set O_CLOEXEC on it 130 + for (size_t j = 0; j < desc->factp->psfa_act_count; j++) { 131 + const struct _psfa_action* act = &desc->factp->psfa_act_acts[j]; 132 + int maybe_fd = act->psfaa_filedes; 133 + 134 + switch (act->psfaa_type) { 135 + case PSFA_DUP2: 136 + case PSFA_FILEPORT_DUP2: 137 + maybe_fd = act->psfaa_dup2args.psfad_newfiledes; 138 + // fall through 139 + 140 + case PSFA_OPEN: 141 + case PSFA_INHERIT: 142 + if (fd == maybe_fd) { 143 + maybe_fd = -1; 144 + } 145 + break; 146 + 147 + default: 148 + break; 149 + } 150 + 151 + // maybe_fd was set to -1, indicating the descriptors matched 152 + if (maybe_fd == -1) { 153 + fd = -1; 154 + break; 155 + } 156 + } 157 + } 158 + 159 + // fd was set to -1, indicating we should skip it 160 + if (fd == -1) { 161 + continue; 162 + } 163 + 128 164 //__simple_kprintf("setting cloexec on %d\n", fd); 129 165 130 166 ret = sys_fcntl(fd, F_GETFD, 0);
+23
src/kernel/emulation/linux/simple.c
··· 149 149 break; 150 150 151 151 } 152 + 153 + case 'o': 154 + { 155 + unsigned int num = va_arg(vl, unsigned int); 156 + char temp[16]; 157 + int count = 0; 158 + 159 + do 160 + { 161 + temp[count++] = '0' + (num % 8); 162 + num /= 8; 163 + } 164 + while (num > 0); 165 + 166 + while (count--) 167 + { 168 + if (offset < max_length) 169 + buf[offset] = temp[count]; 170 + offset++; 171 + } 172 + 173 + break; 174 + } 152 175 } 153 176 154 177 format++;