this repo has no description
1
fork

Configure Feed

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

Ensure /dev/mach gets the same fd on fork

+13 -2
+13 -2
src/kernel/mach_server/client/lkm.c
··· 9 9 10 10 void mach_driver_init(void) 11 11 { 12 + int new_driver_fd; 13 + 12 14 if (driver_fd != -1) 13 15 close(driver_fd); 14 16 15 - driver_fd = open("/dev/mach", O_RDWR | O_CLOEXEC); 16 - if (driver_fd == -1) 17 + new_driver_fd = open("/dev/mach", O_RDWR | O_CLOEXEC); 18 + if (new_driver_fd == -1) 17 19 { 18 20 const char* msg = "Cannot open /dev/mach. Aborting.\nMake sure you have loaded the darling-mach kernel module.\n"; 19 21 20 22 write(2, msg, strlen(msg)); 21 23 abort(); 22 24 } 25 + 26 + // Ensure we get the same fd number, even if lower ones are available 27 + if (driver_fd != -1 && driver_fd != new_driver_fd) 28 + { 29 + dup2(new_driver_fd, driver_fd); 30 + close(new_driver_fd); 31 + } 32 + else 33 + driver_fd = new_driver_fd; 23 34 24 35 if (__real_ioctl(driver_fd, NR_get_api_version, 0) != DARLING_MACH_API_VERSION) 25 36 {