apr-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Nicholas Merryman <nmer...@us.ibm.com>
Subject apr_proc_create hangs on 'modprobe -c'
Date Wed, 03 Aug 2005 20:48:22 GMT
I guess it's not really apr_proc_create that hangs, but apr_proc_wait.

If I execute modprobe -c from the shell, everything works fine and is 
apparently instantaneous.

However, if I try to use apr_proc_create to execute this command, then 
apr_proc_wait(..., APR_WAIT) hangs forever.  Is there a different way I 
should be waiting for the process to end so I can catch its output?

All other commands I've tried work perfectly.  I've checked that the param 
list has 'modprobe' as the first entry, '-c' as the second, and NULL as 
the third.

Is there something I can do to avoid this?  I had a similar problem when 
originally coding this section of code natively, and found a workaround by 
calling waitpid(pid, &childrc, 0).  However, I don't see any option to do 
something similar to that in APR.

Here's how the relevant part of my 'spawn process' function currently 

// variable to set various attributes for child creation
apr_procattr_t *proc_attr;
apr_procattr_io_set(proc_attr, APR_NO_PIPE, APR_FULL_BLOCK, 

// handle for the child process
apr_proc_t hChild;
int exitStatus;
apr_exit_why_e exitWhy;

// execute child then wait for it to finish
if (apr_proc_create(&hChild,name.c_str(),args,NULL,proc_attr,apr_basepool) 
     cout<<"ERROR: CreateProcess Failed";

// wait for child to finish or die

if (!APR_PROC_CHECK_EXIT(exitWhy)) { 
     cout<<"ERROR: SpawnProcess - child terminated abnormally";

output = GetFileContents(hChild.out);  //read contents of child's output

Like I said, this worked with countless other command-line utilities 
(lspci, insmod, lsmod, route -n, etcetcetc), but seems to have something 
against 'modprobe -c'.  Any help would be greatly appreciated.


View raw message