[omniORB] execv fails under POA, works under BOA
Dietmar May
dcmay at dmis.com
Fri Nov 28 11:57:42 GMT 2003
Hello,
I'm seeing a perplexing problem when attempting to exec another program
when using omniORB.
The code is straightforward: it just does a simple fork, execv, and waitpid.
If run AFTER POA initialization in omniORB 4.0.3, or AFTER BOA
initialization in omniORB 2.8.0, the child process (apparently) fails
the execv (because it never completes, even though fork returns a valid
pid), and the process hangs while waiting for the child.
If run AFTER BOA initialization in omniORB 4.0.3, the program is able to
fork and exec just fine.
If run BEFORE the ORB_init() call, it works fine in all cases.
I've tried this on two machines. My platforms are RedHat AS 2.1 with
kernel 2.4.21-4, gcc 2.96-118, and glibc 2.2.4-32.8; and RH 7.2 with
kernel 2.4.20-20.7, gcc 2.96-118, and glibc 2.2.4-33.
I'm wondering if anyone else can reproduce this problem; and hoping for
some ideas as to how to fix or work around it.
Regards,
Dietmar
---- cut -- spawn10.cc ----
//works under omniORB 4.0.3 BOA, not 2.8.0 BOA or 4.0.3 POA
//#define USE_POA
//#define OMNI_VERSION "omniORB2"
#define OMNI_VERSION "omniORB4"
#include <assert.h>
#include <CORBA.h>
#include <stdio.h>
#include <sys/types.h>
#include <unistd.h>
#include <sys/wait.h>
int pspawn (const char* const* argv)
{
assert(argv);
printf("forking ...\n");
pid_t pid = fork();
if(pid == 0)
{ printf("exec'ing ...\n");
execv(argv[0], (char**)argv);
assert(0); //should never get here
}
printf("continuing...\n");
int ret_code = -1;
if(pid != -1) //if -1 ... not open or already
waited
{ int status = 0;
printf("waiting...\n");
if(waitpid(pid, &status, 0) != pid)
printf("PROCESS_WAIT_FAIL");
else if(WIFEXITED(status))
ret_code = WEXITSTATUS(status);
printf("exited...\n");
}
return ret_code;
}
char* arg1[] =
{ "/usr/bin/rcs", "-x.rcs", "-i", "-L", "-ko", "-M", "-t-'TEXT'",
"/tmp/01.rcs", 0
};
char* arg2[] =
{ "/usr/bin/rcs", "-x.rcs", "-i", "-L", "-ko", "-M", "-t-'TEXT'",
"/tmp/02.rcs", 0
};
char* arg3[] =
{ "/bin/ls", "/tmp", 0
};
int main(int argc, char **argv)
{
int code = pspawn(arg3);
code = pspawn(arg1);
//start up the CORBA server
#ifdef USE_POA
CORBA::ORB_var p_ORB = CORBA::ORB_init(argc, argv);
CORBA::Object_var obj = p_ORB->resolve_initial_references("RootPOA");
PortableServer::POA_var p_POA = PortableServer::POA::_narrow(obj);
#else
CORBA::ORB_ptr p_ORB = CORBA::ORB_init(argc, argv, OMNI_VERSION);
CORBA::BOA_ptr p_BOA = p_ORB->BOA_init(argc, argv, OMNI_VERSION "_BOA");
#endif
code = pspawn(arg3);
code = pspawn(arg2);
return code;
}
---- cut -- makefile ----
all : spawn_BOA_403 spawn_POA_403
echo done
spawn_BOA_403 : spawn10.cc
gcc -o$@ -DUSE_BOA -DLINUX -D_MT -mcpu=i686 -D__linux__ -D__x86__
-I/usr/include/omniORB4 -g $< -lc -lpthread -lomnithread -lomniORB4
spawn_POA_403 : spawn10.cc
gcc -o$@ -DUSE_POA -DLINUX -D_MT -mcpu=i686 -D__linux__ -D__x86__
-I/usr/include/omniORB4 -g $< -lc -lpthread -lomnithread -lomniORB4
---- cut -- BOA 4.0.3 output (works) ----
forking ...
exec'ing ...
continuing...
abcdef.tmp 123456.tmp
waiting...
exited...
forking ...
exec'ing ...
RCS file: /tmp/01.rcs
done
continuing...
waiting...
exited...
forking ...
exec'ing ...
continuing...
01.rcs abcdef.tmp 123456.tmp
waiting...
exited...
forking ...
exec'ing ...
RCS file: /tmp/02.rcs
done
continuing...
waiting...
exited...
---- cut -- POA 4.0.3 output (hangs) ----
forking ...
exec'ing ...
continuing...
waiting...
abcdef.tmp 123456.tmp
exited...
forking ...
exec'ing ...
continuing...
waiting...
RCS file: /tmp/01.rcs
done
exited...
forking ...
exec'ing ...
continuing...
waiting...
<<hangs here>>
More information about the omniORB-list
mailing list