diff options
Diffstat (limited to 'win32')
-rw-r--r-- | win32/win32.c | 5 | ||||
-rw-r--r-- | win32/win32.h | 1 | ||||
-rw-r--r-- | win32/win32sck.c | 35 |
3 files changed, 37 insertions, 4 deletions
diff --git a/win32/win32.c b/win32/win32.c index ed12430497..924ee92a7e 100644 --- a/win32/win32.c +++ b/win32/win32.c @@ -581,7 +581,6 @@ do_aspawn(void *vreally, void **vmark, void **vsp) } else { if (status < 0) { - dTHR; if (ckWARN(WARN_EXEC)) Perl_warner(aTHX_ WARN_EXEC, "Can't spawn \"%s\": %s", argv[0], strerror(errno)); status = 255 * 256; @@ -674,7 +673,6 @@ do_spawn2(char *cmd, int exectype) } else { if (status < 0) { - dTHR; if (ckWARN(WARN_EXEC)) Perl_warner(aTHX_ WARN_EXEC, "Can't %s \"%s\": %s", (exectype == EXECF_EXEC ? "exec" : "spawn"), @@ -1875,7 +1873,6 @@ win32_crypt(const char *txt, const char *salt) { dTHXo; #ifdef HAVE_DES_FCRYPT - dTHR; return des_fcrypt(txt, salt, w32_crypt_buffer); #else Perl_croak(aTHX_ "The crypt() function is unimplemented due to excessive paranoia."); @@ -2353,7 +2350,7 @@ win32_fstat(int fd,struct stat *sbufptr) } return rc; #else - return fstat(fd,sbufptr); + return my_fstat(fd,sbufptr); #endif } diff --git a/win32/win32.h b/win32/win32.h index 1640564a65..1040ef1c1a 100644 --- a/win32/win32.h +++ b/win32/win32.h @@ -344,6 +344,7 @@ DllExport void win32_get_child_IO(child_IO_table* ptr); extern FILE * my_fdopen(int, char *); #endif extern int my_fclose(FILE *); +extern int my_fstat(int fd, struct stat *sbufptr); extern int do_aspawn(void *really, void **mark, void **sp); extern int do_spawn(char *cmd); extern int do_spawn_nowait(char *cmd); diff --git a/win32/win32sck.c b/win32/win32sck.c index b83e0d98f1..d169db6d9e 100644 --- a/win32/win32sck.c +++ b/win32/win32sck.c @@ -485,6 +485,41 @@ my_fclose (FILE *pf) return fclose(pf); } +#undef fstat +int +my_fstat(int fd, struct stat *sbufptr) +{ + /* This fixes a bug in fstat() on Windows 9x. fstat() uses the + * GetFileType() win32 syscall, which will fail on Windows 9x. + * So if we recognize a socket on Windows 9x, we return the + * same results as on Windows NT/2000. + * XXX this should be extended further to set S_IFSOCK on + * sbufptr->st_mode. + */ + int osf; + if (!wsock_started || IsWinNT()) + return fstat(fd, sbufptr); + + osf = TO_SOCKET(fd); + if (osf != -1) { + char sockbuf[256]; + int optlen = sizeof(sockbuf); + int retval; + + retval = getsockopt((SOCKET)osf, SOL_SOCKET, SO_TYPE, sockbuf, &optlen); + if (retval != SOCKET_ERROR || WSAGetLastError() != WSAENOTSOCK) { + sbufptr->st_mode = _S_IFIFO; + sbufptr->st_rdev = sbufptr->st_dev = (dev_t)fd; + sbufptr->st_nlink = 1; + sbufptr->st_uid = sbufptr->st_gid = sbufptr->st_ino = 0; + sbufptr->st_atime = sbufptr->st_mtime = sbufptr->st_ctime = 0; + sbufptr->st_size = (off_t)0; + return 0; + } + } + return fstat(fd, sbufptr); +} + struct hostent * win32_gethostbyaddr(const char *addr, int len, int type) { |