summaryrefslogtreecommitdiff
path: root/doio.c
diff options
context:
space:
mode:
authorChip Salzenberg <chip@perl.com>1997-02-10 11:36:54 +1200
committerChip Salzenberg <chip@atlantic.net>1997-02-11 07:29:00 +1200
commit360e57411903f2d16ad89bcdf4a462fc97239653 (patch)
tree545be8efc95aec36642a14df3c3b283562618b48 /doio.c
parentc20f90abda55ce82c41ec2d4843f6344c4730aa2 (diff)
downloadperl-360e57411903f2d16ad89bcdf4a462fc97239653.tar.gz
On C<sysopen(..., O_APPEND)>, call C<fopen(..., "a")>
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);
}