I can not figure out how to pass C's argv to Perl script as ARGV

You don't want to pass argv to the Perl interpreter; you want to pass arguments to it. That's done via 3rd and 4th argument of perl_parse.

char** perlargv = malloc( (argc+3) * sizeof(char*) ); perlargv[0] = "perl"; perlargv[1] = "-e"; perlargv[2] = "1"; perlargv[3] = "--"; int i = argc-1; while (i--) perlargv[i+4] = argv[i+1]; perl_parse(my_perl, NULL, argc+3, perlargv, NULL);

Don't forget to free the memory you allocated for the arguments. This should be done after freeing the Perl interpreter.


I can not figure out how to pass any signal the C program gets, for example Ctrl-C/SIGINT, to the Perl script.

You don't want to "pass signals"; you simply want the Perl program to handle them. That's done by setting $SIG{INT}. The system calls whatever handler was set to handle the signal, whether this was done by C code or by Perl code. You've already proved that this works.

As for not getting the message, could you have been suffering from buffering because you didn't end your messages with a line feed?


In reply to Re: Pass signals and argv from C to embedded Perl by ikegami
in thread Pass signals and argv from C to embedded Perl by bliako

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.