I've got a C program that will get known as having a system get in touch with a Perl script. I'm wondering: Is there's a means I'm able to really host the C program itself within Apache so it may be handled with similar rules Apache has set for example timeout and memory?

Whoever else attempted and what does not work?.

Whether it starts with:

printf("Content-type: text/html\n\n"); /* Or whatever the content type is */

...after which produces some output, and it is inside your cgi-bin, then it must work.

I believe you're searching for how you can write an Apache module. Individuals are restricted by Apache configurations, while for instance a CGI might do anything whatsoever. However, I believe that Apache actually can limit a CGIs memory usage, for example.

(Not always a poor factor, however, you desired to limit things from inside the Apache configuration?)

I would suggest while using FastCGI protocol involving the C program and Apache. The fastcgi development package includes a easy to use C API.

Here's a good example FastCGI C program in the documention:

#include "fcgi_stdio.h" /* fcgi library; put it first*/

#include <stdlib.h>

int count;

void initialize(void)

void main(void)
/* Initialization. */  

/* Response loop. */
  while (FCGI_Accept() >= 0)   {
    printf("Content-type: text/html\r\n"
           "<title>FastCGI Hello! (C, fcgi_stdio library)</title>"
           "<h1>FastCGI Hello! (C, fcgi_stdio library)</h1>"
           "Request number %d running on host <i>%s</i>\n",
            ++count, getenv("SERVER_HOSTNAME"));

If you're able to turn your program right into a library you could utilize Inline::C to hook it directly into your perl code. This could allow you to replace your system() call having a normal perl function call. You may have to work through some data marshalling issues but Inline::C is simpler to utilize than XS.