this repo has no description
1
fork

Configure Feed

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

Proper kqueue behavior across fork() (fixes #581)

+37 -29
+1 -1
src/kernel/emulation/linux/bsdthread/pthread_fchdir.c
··· 15 15 int fd = get_perthread_wd(); 16 16 17 17 if (fd != LINUX_AT_FDCWD) 18 - sys_close(fd); 18 + close_internal(fd); 19 19 20 20 if (newfd == -1) 21 21 newfd = LINUX_AT_FDCWD; // return to per-process wd
+6 -6
src/kernel/emulation/linux/ext/file_handle.c
··· 117 117 p = strtok_r(NULL, " ", &saveptr); 118 118 if (p == NULL) 119 119 { 120 - sys_close(fd_m); 120 + close_internal(fd_m); 121 121 return -ENOENT; 122 122 } 123 123 } ··· 127 127 break; 128 128 } 129 129 130 - sys_close(fd_m); 130 + close_internal(fd_m); 131 131 132 132 if (mount_path == NULL) 133 133 return -ENOENT; ··· 143 143 144 144 int ret = lkm_call(NR_handle_to_path, &args); 145 145 146 - sys_close(fd_m); 146 + close_internal(fd_m); 147 147 148 148 if (ret < 0) 149 149 return errno_linux_to_bsd(ret); ··· 197 197 p = strtok_r(NULL, " ", &saveptr); 198 198 if (p == NULL) 199 199 { 200 - sys_close(fd_m); 200 + close_internal(fd_m); 201 201 return -ENOENT; 202 202 } 203 203 } ··· 207 207 break; 208 208 } 209 209 210 - sys_close(fd_m); 210 + close_internal(fd_m); 211 211 212 212 if (mount_path == NULL) 213 213 return -ENOENT; ··· 220 220 // And now, finally, open the file by handle relative to the mount 221 221 int ret = LINUX_SYSCALL(__NR_open_by_handle_at, fd_m, &ref->fh, linux_flags); 222 222 223 - sys_close(fd_m); 223 + close_internal(fd_m); 224 224 225 225 if (ret < 0) 226 226 ret = errno_linux_to_bsd(ret);
+2 -2
src/kernel/emulation/linux/mach/lkm.c
··· 11 11 #include "../misc/ioctl.h" 12 12 13 13 extern int sys_open(const char*, int, int); 14 - extern int sys_close(int); 14 + extern int close_internal(int); 15 15 extern int sys_write(int, const void*, int); 16 16 extern int sys_kill(int, int); 17 17 extern int sys_getrlimit(int, struct rlimit*); ··· 67 67 // It also means rlim_cur is not above the limit 68 68 // in the following statement. 69 69 int d = sys_dup2(driver_fd, lim.rlim_cur); 70 - sys_close(driver_fd); 70 + close_internal(driver_fd); 71 71 72 72 driver_fd = d; 73 73 }
+2 -2
src/kernel/emulation/linux/misc/gethostuuid.c
··· 15 15 int ret, fd; 16 16 char buf[32]; 17 17 18 - fd = sys_open("/etc/machine-id", O_RDONLY, 0); 18 + fd = sys_open("/Volumes/SystemRoot/etc/machine-id", O_RDONLY, 0); 19 19 if (fd < 0) 20 20 return fd; 21 21 22 22 ret = sys_read(fd, buf, sizeof(buf)); 23 - sys_close(fd); 23 + close_internal(fd); 24 24 25 25 if (ret < 0) 26 26 return ret;
+1 -1
src/kernel/emulation/linux/misc/proc_info.c
··· 381 381 // TODO: Parse additional information (e.g. RSS) 382 382 } 383 383 } 384 - sys_close(fd); 384 + close_internal(fd); 385 385 386 386 if (my_rpi.prp_vip.vip_path[0]) 387 387 {
+1 -1
src/kernel/emulation/linux/misc/sysctl_kern.c
··· 234 234 if (fd >= 0) 235 235 { 236 236 int rd = sys_read(fd, buf, sizeof(buf) - 1); 237 - sys_close(fd); 237 + close_internal(fd); 238 238 239 239 if (rd > 0) 240 240 {
+2 -2
src/kernel/emulation/linux/misc/sysctl_proc.c
··· 113 113 } 114 114 115 115 free_chain(first); 116 - sys_close(fd); 116 + close_internal(fd); 117 117 118 118 // __simple_printf("sysctl_proc returning %d, len %d\n", ret, *buflen); 119 119 return ret; ··· 131 131 if (rd >= 0) 132 132 dst[rd] = '\0'; 133 133 134 - sys_close(fd); 134 + close_internal(fd); 135 135 return rd >= 0; 136 136 } 137 137
+1 -1
src/kernel/emulation/linux/process/execve.c
··· 45 45 if (ret < 0) 46 46 return ret; 47 47 48 - sys_close(fd); 48 + close_internal(fd); 49 49 50 50 bool is_script = false; 51 51
+6 -6
src/kernel/emulation/linux/process/posix_spawn.c
··· 51 51 52 52 // child 53 53 // close the reading side 54 - sys_close(pipe[0]); 54 + close_internal(pipe[0]); 55 55 56 56 no_fork: 57 57 if (desc && desc->attrp) ··· 105 105 if (ret < 0) 106 106 goto fail; 107 107 108 - sys_close(pipe[1]); 108 + close_internal(pipe[1]); 109 109 pipe[1] = ret; 110 110 } 111 111 112 112 switch (act->psfaa_type) 113 113 { 114 114 case PSFA_CLOSE: 115 - ret = sys_close(act->psfaa_filedes); 115 + ret = close_internal(act->psfaa_filedes); 116 116 if (ret != 0) 117 117 goto fail; 118 118 break; ··· 135 135 136 136 if (ret < 0) 137 137 { 138 - sys_close(fd); 138 + close_internal(fd); 139 139 goto fail; 140 140 } 141 141 } ··· 193 193 int err; 194 194 195 195 // close the writing side 196 - sys_close(pipe[1]); 196 + close_internal(pipe[1]); 197 197 198 198 if (my_pid < 0) 199 199 { ··· 206 206 207 207 if (sys_read(pipe[0], &ret, sizeof(ret)) != sizeof(ret)) 208 208 ret = 0; 209 - sys_close(pipe[0]); 209 + close_internal(pipe[0]); 210 210 } 211 211 212 212 out:
+1 -1
src/kernel/emulation/linux/stat/fstatfs.c
··· 94 94 strlcpy(buf->f_mntfromname, mntfrom, sizeof(buf->f_mntfromname)); 95 95 } 96 96 97 - sys_close(fd_m); 97 + close_internal(fd_m); 98 98 return 0; 99 99 } 100 100
+1 -1
src/kernel/emulation/linux/stat/getfsstat.c
··· 77 77 count++; 78 78 } 79 79 80 - sys_close(fd); 80 + close_internal(fd); 81 81 return count; 82 82 } 83 83
+1 -1
src/kernel/emulation/linux/stat/statfs.c
··· 95 95 strlcpy(buf->f_mntfromname, mntfrom, sizeof(buf->f_mntfromname)); 96 96 } 97 97 98 - sys_close(fd); 98 + close_internal(fd); 99 99 return 0; 100 100 } 101 101
+8 -3
src/kernel/emulation/linux/unistd/close.c
··· 27 27 return ret; 28 28 } 29 29 30 - // Special variant for libkqueue to avoid recursion into kqueue_close() 31 - __attribute__((visibility("default"))) 32 - long __close_for_kqueue(int fd) 30 + long close_internal(int fd) 33 31 { 34 32 int ret; 35 33 ··· 40 38 return ret; 41 39 } 42 40 41 + // Special variant for libkqueue to avoid recursion into kqueue_close() 42 + __attribute__((visibility("default"))) 43 + long __close_for_kqueue(int fd) 44 + { 45 + return close_internal(fd); 46 + } 47 +
+1
src/kernel/emulation/linux/unistd/close.h
··· 3 3 4 4 long sys_close(int fd); 5 5 long sys_close_nocancel(int fd); 6 + long close_internal(int fd); 6 7 7 8 #endif 8 9
+2 -1
src/libelfloader/native/threads.c
··· 89 89 pth = ((char*) pth) + stack_size + 0x1000; 90 90 pthread_attr_setstacksize(&attr, 4096); 91 91 92 - pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED); 92 + //pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED); 93 93 94 94 args.pth = pth; 95 95 pthread_create(&nativeLibcThread, &attr, darling_thread_entry, &args); ··· 116 116 { 117 117 // Terminate the Linux thread 118 118 munmap(t_freeaddr, t_freesize); 119 + pthread_detach(pthread_self()); 119 120 return NULL; 120 121 } 121 122
+1
src/libsystem/init.c
··· 248 248 249 249 _pthread_fork_child_postinit(); 250 250 // _libtrace_fork_child(); // no prep work required for the fork 251 + kqueue_atfork(); 251 252 } 252 253 253 254 /*