@@ -453,6 +453,28 @@ w32_close(int fd) {
453
453
}
454
454
}
455
455
456
+ static int
457
+ w32_io_process_fd_flags (struct w32_io * pio , int flags ) {
458
+ DWORD shi_flags ;
459
+ if (flags & ~FD_CLOEXEC ) {
460
+ debug ("fcntl - ERROR unsupported flags %d, io:%p" , flags , pio );
461
+ errno = ENOTSUP ;
462
+ return -1 ;
463
+ }
464
+
465
+ shi_flags = (flags & FD_CLOEXEC ) ? 0 : HANDLE_FLAG_INHERIT ;
466
+
467
+ if (SetHandleInformation (WINHANDLE (pio ), HANDLE_FLAG_INHERIT , shi_flags ) == FALSE) {
468
+ debug ("fcntl - SetHandleInformation failed %d, io:%p" ,
469
+ GetLastError (), pio );
470
+ errno = EOTHER ;
471
+ return -1 ;
472
+ }
473
+
474
+ pio -> fd_flags = flags ;
475
+ return 0 ;
476
+ }
477
+
456
478
int
457
479
w32_fcntl (int fd , int cmd , ... /* arg */ ) {
458
480
va_list valist ;
@@ -467,11 +489,9 @@ w32_fcntl(int fd, int cmd, ... /* arg */) {
467
489
fd_table .w32_ios [fd ]-> fd_status_flags = va_arg (valist , int );
468
490
return 0 ;
469
491
case F_GETFD :
470
- return fd_table .w32_ios [fd ]-> fd_flags ;
471
- return 0 ;
492
+ return fd_table .w32_ios [fd ]-> fd_flags ;
472
493
case F_SETFD :
473
- fd_table .w32_ios [fd ]-> fd_flags = va_arg (valist , int );
474
- return 0 ;
494
+ return w32_io_process_fd_flags (fd_table .w32_ios [fd ], va_arg (valist , int ));
475
495
default :
476
496
errno = EINVAL ;
477
497
debug ("fcntl - ERROR not supported cmd:%d" , cmd );
@@ -725,11 +745,6 @@ w32_alarm(unsigned int seconds) {
725
745
return 0 ;
726
746
}
727
747
728
- sighandler_t w32_signal (int signum , sighandler_t handler ) {
729
- /*TODO - implement signal()*/
730
- return 0 ;
731
- }
732
-
733
748
int
734
749
w32_temp_DelChildToWatch (HANDLE processtowatch ) {
735
750
return 0 ;
0 commit comments