Re: perlembed: Interrupt call_pv
[email protected] (Fedor Sumkin) Sat, 25 Jul 2015 15:07:07 +0300
| Newsgroups | perl.xs,perl.beginners |
|---|---|
| Message-ID | <CAEoYLjN007quGv8E-NMy8C1GjvQv7_Un3Gq8zYdy38Wtr6aPHQ@mail.gmail.com> |
--047d7bae48f49dd86e051bb1f5fe Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Hello everyone! I am using Perl to embed it in C application, I need to have an ability to interrupt Perl function which have been invoked with `call_pv`. As function is invoked, it is blocking thread where it is running. So, I see the only way to interrupt this blocking thread - via killing this thread with native "thread kill" functionality. But killing this thread results on program crash( (F)atal error -- Can't undef active subroutine during global destruction) and this can't be handled with exceptions or via other way. I am looking for correct way of handling the interruption of running perl function in C. So, is there any appropriate way to do this? Regards, Fedor On Sat, Jul 25, 2015 at 3:06 PM, Fedor Sumkin <[email protected]> wrote: > Hello Shlomi, > > Thanks for your suggestion, I'll duplicate question to perl-xs and will > try to answer to your second question in next reply. > > Regards, > Fedor > > On Sat, Jul 25, 2015 at 12:23 PM, Shlomi Fish <[email protected]> > wrote: > >> Hi Fedor, >> >> On Fri, 24 Jul 2015 15:17:58 +0300 >> Fedor Sumkin <[email protected]> wrote: >> >> > Hello, >> > >> > I am using Perl to embed it in C application( >> > http://perldoc.perl.org/perlembed.html). >> > >> > I need to have a possibility to interrupt perl function invoked from C >> code >> > via `call_pv`/`call_*` methods. >> > >> > I tried achieving this via destroying running perl context, but this >> > resulted on fatal error "Can't undef active subroutine during global >> > destruction". >> > >> > So, how can I interrupt running perl func from C? >> > >> >> Two notes: >> >> 1. XS/C-ext/C-embed/etc. are likely out of the scope of >> [email protected] . >> You may have better luck here: http://lists.perl.org/list/perl-xs.html . >> >> 2. It's not clear to me from reading your message what exactly your issu= e >> is. >> Can you explain? >> >> Regards, >> >> Shlomi Fish >> >> >> -- >> ----------------------------------------------------------------- >> Shlomi Fish http://www.shlomifish.org/ >> The Case for File Swapping - http://shlom.in/file-swap >> >> Chuck Norris can end world hunger, but he thinks that hungry people make >> humanity a more challenging adversary. >> =E2=80=94 http://www.shlomifish.org/humour/bits/facts/Chuck-Norris/ >> >> Please reply to list if it's a mailing list post - http://shlom.in/reply >> . >> >> -- >> To unsubscribe, e-mail: [email protected] >> For additional commands, e-mail: [email protected] >> http://learn.perl.org/ >> >> >> > --047d7bae48f49dd86e051bb1f5fe Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable <div dir=3D"ltr">Hello everyone!<br><br>I am using Perl to embed it in C ap= plication, I need to have an ability to interrupt Perl function which<br>ha= ve been invoked with `call_pv`. As function is invoked, it is blocking thre= ad where it is running.<br><br>So, I see the only way to interrupt this blo= cking thread - via killing this thread with native "thread kill" = functionality.<br><br>But killing this thread results on program crash( (F)= atal error -- Can't undef active subroutine during global destruction)<= br>and this can't be handled with exceptions or via other way.<br><br>I= am looking for correct way of handling the interruption of running perl fu= nction in C.<br>So, is there any appropriate way to do this?<br><br>Regards= ,<br>Fedor <br></div><div class=3D"gmail_extra"><br><div class=3D"gmail_quo= te">On Sat, Jul 25, 2015 at 3:06 PM, Fedor Sumkin <span dir=3D"ltr"><<a = href=3D"mailto:[email protected]" target=3D"_blank">[email protected]</= a>></span> wrote:<br><blockquote class=3D"gmail_quote" style=3D"margin:0= 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir=3D"ltr"><di= v><div><div>Hello Shlomi,<br><br></div><div>Thanks for your suggestion, I&#= 39;ll duplicate question to perl-xs and will try to answer to your second q= uestion in next reply.<br></div><div><br></div></div></div><div>Regards, <b= r></div>Fedor </div><div class=3D"gmail_extra"><br><div class=3D"gmail_quot= e"><span class=3D"">On Sat, Jul 25, 2015 at 12:23 PM, Shlomi Fish <span dir= =3D"ltr"><<a href=3D"mailto:[email protected]" target=3D"_blank">sh= [email protected]</a>></span> wrote:<br></span><blockquote class=3D"g= mail_quote" style=3D"margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-l= eft:1ex">Hi Fedor,<br> <span><span class=3D""><br> On Fri, 24 Jul 2015 15:17:58 +0300<br></span><span class=3D""> Fedor Sumkin <<a href=3D"mailto:[email protected]" target=3D"_blank">q= [email protected]</a>> wrote:<br> <br> > Hello,<br> ><br> > I am using Perl to embed it in C application(<br> </span></span><span>> <a href=3D"http://perldoc.perl.org/perlembed.html"= rel=3D"noreferrer" target=3D"_blank">http://perldoc.perl.org/perlembed.htm= l</a>).<span class=3D""><br> ><br> > I need to have a possibility to interrupt perl function invoked from C= code<br> > via `call_pv`/`call_*` methods.<br> ><br> > I tried achieving this via destroying running perl context, but this<b= r> > resulted on fatal error "Can't undef active subroutine during= global<br> > destruction".<br> ><br> > So, how can I interrupt running perl func from C?<br> ><br> <br> </span></span>Two notes:<br> <br> 1. XS/C-ext/C-embed/etc. are likely out of the scope of <a href=3D"mailto:b= [email protected]" target=3D"_blank">[email protected]</a> .<br> You may have better luck here: <a href=3D"http://lists.perl.org/list/perl-x= s.html" rel=3D"noreferrer" target=3D"_blank">http://lists.perl.org/list/per= l-xs.html</a> .<span class=3D""><br> <br> 2. It's not clear to me from reading your message what exactly your iss= ue is.<br> Can you explain?<br> <br> Regards,<br> <br> =C2=A0 =C2=A0 =C2=A0 =C2=A0 Shlomi Fish<br> </span><span><font color=3D"#888888"><br> <br> --<br> -----------------------------------------------------------------<br> Shlomi Fish=C2=A0 =C2=A0 =C2=A0 =C2=A0<a href=3D"http://www.shlomifish.org/= " rel=3D"noreferrer" target=3D"_blank">http://www.shlomifish.org/</a><br> The Case for File Swapping - <a href=3D"http://shlom.in/file-swap" rel=3D"n= oreferrer" target=3D"_blank">http://shlom.in/file-swap</a><span class=3D"">= <br> <br> Chuck Norris can end world hunger, but he thinks that hungry people make<br= > humanity a more challenging adversary.<br></span> =C2=A0 =C2=A0 =E2=80=94 <a href=3D"http://www.shlomifish.org/humour/bits/fa= cts/Chuck-Norris/" rel=3D"noreferrer" target=3D"_blank">http://www.shlomifi= sh.org/humour/bits/facts/Chuck-Norris/</a><br> <br> Please reply to list if it's a mailing list post - <a href=3D"http://sh= lom.in/reply" rel=3D"noreferrer" target=3D"_blank">http://shlom.in/reply</a= > .<span class=3D"HOEnZb"><font color=3D"#888888"><br> <br> --<br> To unsubscribe, e-mail: <a href=3D"mailto:[email protected]" t= arget=3D"_blank">[email protected]</a><br> For additional commands, e-mail: <a href=3D"mailto:[email protected]"= target=3D"_blank">[email protected]</a><br> <a href=3D"http://learn.perl.org/" rel=3D"noreferrer" target=3D"_blank">htt= p://learn.perl.org/</a><br> <br> <br> </font></span></font></span></blockquote></div><br></div> </blockquote></div><br></div> --047d7bae48f49dd86e051bb1f5fe--