summaryrefslogtreecommitdiff
path: root/ext/XS
diff options
context:
space:
mode:
Diffstat (limited to 'ext/XS')
-rw-r--r--ext/XS/Typemap/Typemap.t6
-rw-r--r--ext/XS/Typemap/Typemap.xs11
2 files changed, 10 insertions, 7 deletions
diff --git a/ext/XS/Typemap/Typemap.t b/ext/XS/Typemap/Typemap.t
index 0cf1ab3481..1699c991dc 100644
--- a/ext/XS/Typemap/Typemap.t
+++ b/ext/XS/Typemap/Typemap.t
@@ -314,11 +314,7 @@ if (defined $fh) {
ok(print $fh "$lines[1]");
# close it using XS
- # This works fine but causes a segmentation fault during global
- # destruction when the glob associated with this filehandle is
- # tidied up.
-# ok( T_STDIO_close( $fh ) );
- ok(close($fh)); # using perlio to close the glob works fine
+ ok( T_STDIO_close( $fh ) );
# open from perl, and check contents
open($fh, "< $testfile");
diff --git a/ext/XS/Typemap/Typemap.xs b/ext/XS/Typemap/Typemap.xs
index feed61b904..853b4abd2b 100644
--- a/ext/XS/Typemap/Typemap.xs
+++ b/ext/XS/Typemap/Typemap.xs
@@ -795,10 +795,17 @@ T_STDIO_open( file )
RETVAL
SysRet
-T_STDIO_close( stream )
- FILE * stream
+T_STDIO_close( f )
+ PerlIO * f
+ PREINIT:
+ FILE * stream;
CODE:
+ /* Get the FILE* */
+ stream = PerlIO_findFILE( f );
RETVAL = xsfclose( stream );
+ /* Release the FILE* from the PerlIO system so that we do
+ not close the file twice */
+ PerlIO_releaseFILE(f,stream);
OUTPUT:
RETVAL