[svn.haxx.se] · SVN Dev · SVN Users · SVN Org · TSVN Dev · TSVN Users · Subclipse Dev · Subclipse Users · this month's index

APR process questions

From: Karl Fogel <kfogel_at_galois.collab.net>
Date: 2000-11-11 00:00:27 CET

Greg, maybe you know the answers to these?

I am starting up a "diff" process using apr_create_process(). Then I
wait for it to finish with apr_wait_proc().

Unfortunately, apr_wait_proc() doesn't return the subprocess's exit
status. Instead, it returns one of two values: APR_CHILD_DONE or
APR_CHILD_NOTDONE.

I could use apr_wait_all_procs() instead, which claims to return the
exit status of the child, but that seems silly when I have exactly one
subprocess and I know I want to wait until its done.

And anyway, when I look at the code for both funcs in
threadproc/unix/proc.c, the latter really behaves just like the former
-- neither actually tells you the child's exit status, they just
return APR_CHILD_DONE or APR_CHILD_NOTDONE.

I would sure love that status. :-)

One solution, to keep things backwards compatible, would be to add a
field to struct apr_proc_t, `apr_int32_t exit_status' for example.
Examining this field before you have wait()ed for the proc would be
meaningless. But afterwards, the field would hold the child's exit
code (maybe with WEXITSTATUS() applied -- that is, bits >255 masked
out -- or maybe not, I haven't thought that through carefully yet).

Should I make a patch for this, or is there another way to do what I
want to do?

For reference, the code I'm working in is libsvn_wc/get_editor.c,
search for this comment:

   /* kff todo: trying to drive diff the apr way */

Unrelatedly, I think there's a documentation confusion in
apr_thread_proc.h, but I'd like to run it by you to make sure:

The documentation for apr_wait_all_procs() says `proc' should point to
NULL on entry (though suspiciously it doesn't say why). I don't think
it could do anything useful with a null `apr_proc_t *proc' argument --
`apr_proc_t **proc' would be be the prototype, in that case. The code
makes me think it takes `apr_proc_t *proc', but pointing to a
preallocated apr_proc_t structure rather than null.

Should I make a doc patch, or does all of the above indicate that I am
completely misunderstanding APR process control? :-)

-Karl

/**
 * Wait for a child process to die
 * @param proc The process handle that corresponds to the desired child process
 * @param waithow How should we wait. One of:
 * <PRE>
 * APR_WAIT -- block until the child process dies.
 * APR_NOWAIT -- return immediately regardless of if the
 * child is dead or not.
 * </PRE>
 * @tip The childs status is in the return code to this process. It is one of:
 * <PRE>
 * APR_CHILD_DONE -- child is no longer running.
 * APR_CHILD_NOTDONE -- child is still running.
 * </PRE>
 */
apr_status_t apr_wait_proc(apr_proc_t *proc, apr_wait_how_e waithow);

/**
 * Wait for any current child process to die and return information
 * about that child.
 * @param proc Pointer to NULL on entry, will be filled out with child's
 * information
 * @param status The returned exit status of the child, if a child process dies
 * On platforms that don't support obtaining this information,
 * the status parameter will be returned as APR_ENOTIMPL.
 * @param waithow How should we wait. One of:
 * <PRE>
 * APR_WAIT -- block until the child process dies.
 * APR_NOWAIT -- return immediately regardless of if the
 * child is dead or not.
 * </PRE>
 * @param p Pool to allocate child information out of.
 */

apr_status_t apr_wait_all_procs(apr_proc_t *proc, apr_wait_t *status,
                                apr_wait_how_e waithow, apr_pool_t *p);
Received on Sat Oct 21 14:36:14 2006

This is an archived mail posted to the Subversion Dev mailing list.

This site is subject to the Apache Privacy Policy and the Apache Public Forum Archive Policy.