develooper Front page | perl.perl5.porters | Postings from October 2001

perl_destruct() closing std{in,out,err}

Thread Next
From:
Doug MacEachern
Date:
October 26, 2001 16:51
Subject:
perl_destruct() closing std{in,out,err}
Message ID:
Pine.LNX.4.21.0110261650270.21661-100000@mako.covalent.net
with bleedperl@12695, something in perl_destruct() closes std{in,out,err},
the program below prints:

alloc
construct
parse
run

(does not print "destruct" or "free")

strace outputs:

close(2)                                = 0
close(1)                                = 0
munmap(0x40017000, 4096)                = 0
close(0)                                = 0
_exit(666)                              = ?

compile with:
% gcc -g -o perl_test perl_test.c `perl -MExtUtils::Embed -e ccopts -e ldopts`

/* perl_test.c */

#include <EXTERN.h>
#include <perl.h>

#define my_puts(a) if(puts(a) < 0) exit(666)

int main(int argc, char **argv, char **env)
{
    PerlInterpreter *my_perl = perl_alloc();

    my_puts("alloc");

    perl_construct(my_perl);

    my_puts("construct");

    perl_parse(my_perl, NULL, argc, argv, env);

    my_puts("parse");

    perl_run(my_perl); 

    my_puts("run");

    perl_destruct(my_perl); 

    my_puts("destruct");

    perl_free(my_perl); 

    my_puts("free");

    return 1;
}



Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About