aboutsummaryrefslogtreecommitdiff
path: root/src/syscall
diff options
context:
space:
mode:
Diffstat (limited to 'src/syscall')
-rw-r--r--src/syscall/syscall_windows.go8
-rw-r--r--src/syscall/types_windows.go4
2 files changed, 12 insertions, 0 deletions
diff --git a/src/syscall/syscall_windows.go b/src/syscall/syscall_windows.go
index 817eeb6811..3e63897b6b 100644
--- a/src/syscall/syscall_windows.go
+++ b/src/syscall/syscall_windows.go
@@ -468,6 +468,14 @@ func Open(name string, flag int, perm uint32) (fd Handle, err error) {
if flag&O_TRUNC == O_TRUNC &&
(createmode == OPEN_EXISTING || (createmode == OPEN_ALWAYS && err == ERROR_ALREADY_EXISTS)) {
err = Ftruncate(h, 0)
+ if err == _ERROR_INVALID_PARAMETER {
+ // ERROR_INVALID_PARAMETER means truncation is not supported on this file handle.
+ // Unix's O_TRUNC specification says to ignore O_TRUNC on named pipes and terminal devices.
+ // We do the same here.
+ if t, err1 := GetFileType(h); err1 == nil && (t == FILE_TYPE_PIPE || t == FILE_TYPE_CHAR) {
+ err = nil
+ }
+ }
if err != nil {
CloseHandle(h)
return InvalidHandle, err
diff --git a/src/syscall/types_windows.go b/src/syscall/types_windows.go
index b40b455e7d..3c6d18a850 100644
--- a/src/syscall/types_windows.go
+++ b/src/syscall/types_windows.go
@@ -35,6 +35,10 @@ const (
)
const (
+ _ERROR_INVALID_PARAMETER Errno = 87
+)
+
+const (
// Invented values to support what package os expects.
O_RDONLY = 0x00000
O_WRONLY = 0x00001