I am sorry for the delay in my response.

>an example of how you are exiting the Perl script (i.e. are you using exit?)
Yes, I am using exit like folloing code.

---- perl script ----
#unlock the file and output the log
&exit_instance;

#return exit code to C program.
POSIX:_exit($ret ? EXIT_SUCCESS : EXIT_FAILURE);
---- perl script ----

>an example of how you are spawning/forking the Perl script from your C program,
>and how you wait for it to finish and process the return code.
The daemon run C programs using CreateProcess() in Windows.
And, C program run a Perl script using system().
---- Daemon ----
if( TRUE != CreateProcess( NULL, commandLine, &sa, &sa, TRUE, CREATE_NEW_PROCESS_GROUP | NORMAL_PRIORITY_CLASS, NULL, NULL,
			&StartInfo, &ProcInfo ) ) {
	dRet = GetLastError();
	LOGOUTPUT_ERR_WITHNUM_WIN( 0, MS_M_CREATEPROC_E, dRet );
	return dRet;
}
---- Daemon ----

---- C program ----
#szCmd means perl command
if (-1 == (ret = system(szCmd))) {
	err = errno;
	printf("Execution failure.%d\n", err);
	return EXIT_FAILURE;
}
return ret;
---- C program ----
As an image, look at the following flow.
1. daemon -(launch)-> C program(1)
          -(launch)-> C program(2)
          -(launch)-> C program(3)

2. C program(1) -(launch)-> perl script(1)
   C program(2) -(launch)-> perl script(2)
   C program(3) -(launch)-> perl script(3)

3. perl script(1) -> get information from ESX server and write it to text
   perl script(2) -> wait for information about ESX server(i.e. wait until perl script(1) write a text)
   perl script(3) -> wait for information about ESX server(i.e. wait until perl script(1) write a text)

4. after (3), each perl script process get information from text, and analyze it.
As I already wrote, perl script outputs the logs at the start and the end of operation.
From the logs ,we could see that the process had been finished successfully.
But, after the logs had been written, the exit code that should be returned from Perl command to C command had not been returned.
I really do not know, how to solve this problem.


In reply to Re^2: The return code from Perl is not returned to the application by ueua
in thread The return code from Perl is not returned to the application by ueua

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.