Reputation: 419
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.
Upvotes: 1
Views: 132
Reputation: 1667
12 years late, only for advice Windows developers: dont use apr_file_namedpipe_create.
In Windows is not implemented, even in APR v1.7.5
I take this from source code:
APR_DECLARE(apr_status_t) apr_file_namedpipe_create(const char *filename,
apr_fileperms_t perm,
apr_pool_t *pool)
{
/* Not yet implemented, interface not suitable.
* Win32 requires the named pipe to be *opened* at the time it's
* created, and to do so, blocking or non blocking must be elected.
*/
return APR_ENOTIMPL;
}
Upvotes: 0