Stanley Hopcroft <[EMAIL PROTECTED]> writes:
>Dear Ladies and Gentlemen,
>
>I have a _horrible_ small embedded application that 'works' on
>unthreaded 5.8.0 (FreeBSD) but not on a threaded 5.8.0.
>
>
>Here is most of the rubbish ..
>
>char command_line[MAX_COMMANDLINE_LENGTH];
>char *ap ;
>int exitstatus;
>int pclose_result;
> 
>dTHX;

A dTHX up here is no use - you have not got a "my_perl" constructed 
yet.

call_argv() becomes

Perl_call_argv(aTHX_ ...)

where aTHX_ uses the the THX that is in scope - in your 
case it will be NULL from that dTHX

>dSP;

This is suspect as well.

> 
>if((perl=perl_alloc())==NULL){
>        snprintf(buffer,sizeof(buffer),"Error: Could not allocate memory
>for embedded Perl interpreter!\n");
>        buffer[sizeof(buffer)-1]='\x0';
>        printf("%s\n", buffer);
>        exit(1);
>        }
>perl_construct(perl);
>exitstatus=perl_parse(perl,xs_init,2,embedding,NULL);
>if(!exitstatus){
> 
>exitstatus=perl_run(perl);
> 
>while(printf("Enter file name: ") &&
>fgets(command_line,sizeof(command_line),stdin)){

Quick fix is to move 

dTHX; 

here


> 
>        /* call the subroutine, passing it the filename as an argument
>         */
> 
>        command_line[strlen(command_line) -1] = '\0';
> 
>        strncpy(fname,command_line,strcspn(command_line," "));
>        fname[strcspn(command_line," ")] = '\x0';
>        args[0] = fname ;
>        args[3] = command_line + strlen(fname) + 1 ;
> 
>        /* generate a temporary filename to which stdout can be
>         redirected. */
>        sprintf(tmpfname,"/tmp/embedded%d",getpid());
>        args[2] = tmpfname;
> 
>        /* call our perl interpreter to compile and optionally cache the
>           command
>         */
>        call_argv("Embed::Persistent::eval_file", G_DISCARD | G_EVAL,
>args);
> 
>        call_argv("Embed::Persistent::run_package", G_DISCARD | G_EVAL,
>args);
> 
>        /* check return status  */
>        if(SvTRUE(ERRSV)){
>                pclose_result=-2;
>                printf("embedded perl ran %s with error
>%s\n",fname,SvPV(ERRSV,PL_na));
>                }
> 
>        /* read back stdout from script */
>        fp=fopen(tmpfname, "r");
> 
>        /* default return string in case nothing was returned */
>        strcpy(plugin_output,"(No output!)");
> 
>        fgets(plugin_output,sizeof(plugin_output)-1,fp);
>        plugin_output[sizeof(plugin_output)-1]='\x0';
>        fclose(fp);
>        unlink(tmpfname);
>        printf("embedded perl plugin output was %d,%s\n", pclose_result,
>plugin_output);
>        }
>}
> 
>All comments gratefully received.
>
>[EMAIL PROTECTED] new2_mini_epn]$ perl -V 
>Summary of my perl5 (revision 5.0 version 8 subversion 0) configuration:
>  Platform:
>    osname=linux, osvers=2.4.19-2mdkenterprise,
>archname=i386-linux-thread-multi
>    uname='linux no.mandrakesoft.com 2.4.19-2mdkenterprise #1 smp tue
>aug 13 00:17:42 cest 2002 i686 unknown unknown gnulinux '
>    config_args='-des -Darchname=i386-linux -Dcc=gcc -Doptimize=-O3
>-fomit-frame-pointer -pipe -mcpu=pentiumpro -march=i586 -ffast-math
>-fno-strength-reduce -Dprefix=/usr -Dvendorprefix=/usr -Dsiteprefix=/usr
>-Dman3ext=3pm -Dcf_by=MandrakeSoft -Dmyhostname=localhost
>[EMAIL PROTECTED] -Dd_dosuid -Ud_csh -Duseshrplib -Dusethreads'
>    hint=recommended, useposix=true, d_sigaction=define
>    usethreads=define use5005threads=undef useithreads=define
>usemultiplicity=define
>    useperlio=define d_sfio=undef uselargefiles=define usesocks=undef
>    use64bitint=undef use64bitall=undef uselongdouble=undef
>    usemymalloc=n, bincompat5005=undef
>  Compiler:
>    cc='gcc', ccflags ='-D_REENTRANT -D_GNU_SOURCE -fno-strict-aliasing
>-D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -I/usr/include/gdbm',
>    optimize='-O3 -fomit-frame-pointer -pipe -mcpu=pentiumpro
>-march=i586 -ffast-math -fno-strength-reduce',
>    cppflags='-D_REENTRANT -D_GNU_SOURCE -fno-strict-aliasing
>-I/usr/include/gdbm'
>    ccversion='', gccversion='3.2 (Mandrake Linux 9.0 3.2-1mdk)',
>gccosandvers=''
>    intsize=4, longsize=4, ptrsize=4, doublesize=8, byteorder=1234
>    d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=12
>    ivtype='long', ivsize=4, nvtype='double', nvsize=8, Off_t='off_t',
>lseeksize=8
>    alignbytes=4, prototype=define
>  Linker and Libraries:
>    ld='gcc', ldflags =' -L/usr/local/lib'
>    libpth=/usr/local/lib /lib /usr/lib
>    libs=-lnsl -lndbm -lgdbm -ldl -lm -lpthread -lc -lcrypt -lutil
>    perllibs=-lnsl -ldl -lm -lpthread -lc -lcrypt -lutil
>    libc=/lib/libc-2.2.5.so, so=so, useshrplib=true, libperl=libperl.so
>    gnulibc_version='2.2.5'
>  Dynamic Linking:
>    dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=undef, ccdlflags='-rdynamic
>-Wl,-rpath,/usr/lib/perl5/5.8.0/i386-linux-thread-multi/CORE'
>    cccdlflags='-fpic', lddlflags='-shared -L/usr/local/lib'
>
>
>Characteristics of this binary (from libperl): 
>  Compile-time options: MULTIPLICITY USE_ITHREADS USE_LARGE_FILES
>PERL_IMPLICIT_CONTEXT
>  Built under linux
>  Compiled at Sep  6 2002 23:24:44
>  @INC:
>    /usr/lib/perl5/5.8.0/i386-linux-thread-multi
>    /usr/lib/perl5/5.8.0
>    /usr/lib/perl5/site_perl/5.8.0/i386-linux-thread-multi
>    /usr/lib/perl5/site_perl/5.8.0
>    /usr/lib/perl5/site_perl/5.6.1
>    /usr/lib/perl5/site_perl
>    /usr/lib/perl5/vendor_perl/5.8.0/i386-linux-thread-multi
>    /usr/lib/perl5/vendor_perl/5.8.0
>    /usr/lib/perl5/vendor_perl
>    .
>[EMAIL PROTECTED] new2_mini_epn]$ 
>
>Yours sincerely.
>
>-- 
>------------------------------------------------------------------------
>Stanley Hopcroft
>------------------------------------------------------------------------
>
>'...No man is an island, entire of itself; every man is a piece of the
>continent, a part of the main. If a clod be washed away by the sea,
>Europe is the less, as well as if a promontory were, as well as if a
>manor of thy friend's or of thine own were. Any man's death diminishes
>me, because I am involved in mankind; and therefore never send to know
>for whom the bell tolls; it tolls for thee...'
>
>from Meditation 17, J Donne.
-- 
Nick Ing-Simmons
http://www.ni-s.u-net.com/

Reply via email to