summaryrefslogtreecommitdiff
path: root/doio.c
diff options
context:
space:
mode:
Diffstat (limited to 'doio.c')
-rw-r--r--doio.c13
1 files changed, 10 insertions, 3 deletions
diff --git a/doio.c b/doio.c
index 31c9a35ff2..ec3181e2d4 100644
--- a/doio.c
+++ b/doio.c
@@ -118,9 +118,16 @@ PerlIO *supplied_fp;
if (fd == -1)
fp = NULL;
else {
- fp = PerlIO_fdopen(fd, ((result == 0) ? "r"
- : (result == 1) ? "w"
- : "r+"));
+ char *fpmode;
+ if (result == 0)
+ fpmode = "r";
+#ifdef O_APPEND
+ else if (rawmode & O_APPEND)
+ fpmode = (result == 1) ? "a" : "a+";
+#endif
+ else
+ fpmode = (result == 1) ? "w" : "r+";
+ fp = PerlIO_fdopen(fd, fpmode);
if (!fp)
close(fd);
}