How to use apr_file_namedpipe_create()

129 views Asked by At

This may be a very simple question: How to use apr_file_namedpipe_create() function from Apache Portable Runtime library to create a named pipe, and then use that named pipe for child-parent communication. The child process is being created using apr_proc_create() function and it waits for the data to appear in the input-named pipe sent by the Apache/parent process.

I am not sure about the sequence of the APIs to call. I can think of doing this way but still confused.

apr_procattr_t *attr;
apr_proc_t newproc;

const char *progname;
const char *args[100];

apr_file_namedpipe_create("/tmp/ipipe", 0666, p);
apr_procattr_create(&attr, p)
apr_procattr_io_set(attr, APR_CHILD_BLOCK, APR_CHILD_BLOCK, APR_CHILD_BLOCK)
apr_procattr_cmdtype_set(attr, APR_PROGRAM_PATH);
apr_proc_create(&newproc, progname, args, NULL, attr, p);

How can I specify that child process to use '/tmp/ipipe' for all input from its parent process/Apache? In the child process I am reading from /tmp/ipipe', but is that enough? Or I need to specify here as well that child process will use that named pipe for input? What would be the parameters for apr_procattr_io_set() in that case or there are some other function to do this?

APR appears to have very little documentation/sample codes, so I was unable to google it. Any hints or suggestions?

I am running on Linux environment.

0

There are 0 answers