Captive_GLogFunc corba_GLogFunc_object;
Captive_CaptiveIOChannel corba_CaptiveIOChannel_object;
int corba_parentheart_fds_1;
+ pid_t corba_child_pid;
};
struct _CaptiveVfsObjectClass {
GObjectClass parent_class;
#include <unistd.h>
#include "server-GLogFunc.h"
#include "server-CaptiveIOChannel.h"
+#include <signal.h> /* for kill(2) */
+#include <wait.h>
GnomeVFSResult captive_sandbox_parent_vfs_new(CaptiveVfsObject *captive_vfs_object)
&captive_vfs_object->corba_Vfs_object, /* corba_Vfs_object_return */
&captive_vfs_object->corba_GLogFunc_object, /* corba_GLogFunc_object_return */
&captive_vfs_object->corba_CaptiveIOChannel_object, /* corba_CaptiveIOChannel_object_return */
- &captive_vfs_object->corba_parentheart_fds_1); /* parentheart_fds_1_return */
+ &captive_vfs_object->corba_parentheart_fds_1, /* parentheart_fds_1_return */
+ &captive_vfs_object->corba_child_pid); /* child_pid_return */
g_return_val_if_fail(errbool==TRUE,GNOME_VFS_ERROR_GENERIC);
return GNOME_VFS_OK;
CORBA_Object_release(captive_vfs_object->corba_Vfs_object,&captive_corba_ev);
g_assert(validate_CORBA_Environment(&captive_corba_ev));
- /* Shutdown 'GLogFunc' servant */
+ /* Shutdown 'GLogFunc' servant. */
GLogFunc_servant=PortableServer_POA_reference_to_servant(captive_corba_poa,
captive_vfs_object->corba_GLogFunc_object,&captive_corba_ev);
g_assert(validate_CORBA_Environment(&captive_corba_ev));
impl_Captive_GLogFunc__destroy(GLogFunc_servant,&captive_corba_ev);
g_assert(validate_CORBA_Environment(&captive_corba_ev));
- /* Shutdown 'CaptiveIOChannel' servant */
+ /* Shutdown 'CaptiveIOChannel' servant. */
CaptiveIOChannel_servant=PortableServer_POA_reference_to_servant(captive_corba_poa,
captive_vfs_object->corba_CaptiveIOChannel_object,&captive_corba_ev);
g_assert(validate_CORBA_Environment(&captive_corba_ev));
impl_Captive_CaptiveIOChannel__destroy(CaptiveIOChannel_servant,&captive_corba_ev);
g_assert(validate_CORBA_Environment(&captive_corba_ev));
+ /* Close parentheart_fd_write. */
if (captive_vfs_object->corba_parentheart_fds_1!=-1) {
- errint=close(captive_vfs_object->corba_parentheart_fds_1); /* close parentheart_fd_write */
+ errint=close(captive_vfs_object->corba_parentheart_fds_1);
g_return_val_if_fail(errint==0,FALSE);
}
+ /* Cleanup the child process. */
+ if (captive_vfs_object->corba_child_pid!=(pid_t)-1) {
+ /*
+ *
+ *
+ *
+ *
+ */
+ kill(captive_vfs_object->corba_child_pid,SIGKILL); /* errors ignored */
+ /*
+ *
+ */
+ waitpid(captive_vfs_object->corba_child_pid,
+ NULL, /* status */
+ WNOHANG); /* options */
+ }
+
return r;
}
g_return_if_fail(Vfs_IOR!=NULL);
g_return_if_fail(corba_Vfs_object_return!=NULL);
g_return_if_fail(corba_GLogFunc_object_return!=NULL);
+ g_return_if_fail(corba_CaptiveIOChannel_object_return!=NULL);
Vfs_object=CORBA_ORB_string_to_object(captive_corba_orb,Vfs_IOR,&captive_corba_ev);
g_assert(validate_CORBA_Environment(&captive_corba_ev));
gboolean captive_sandbox_spawn(CaptiveVfsObject *child_captive_vfs_object,
Captive_Vfs *corba_Vfs_object_return,Captive_GLogFunc *corba_GLogFunc_object_return,
- Captive_CaptiveIOChannel *corba_CaptiveIOChannel_object_return,int *parentheart_fds_1_return)
+ Captive_CaptiveIOChannel *corba_CaptiveIOChannel_object_return,int *parentheart_fds_1_return,
+ pid_t *child_pid_return)
{
/* Vfs_IOR_fds[0] for reading by sandbox_parent() - client,
* Vfs_IOR_fds[1] for writing by sandbox_child() - server
g_return_val_if_fail(corba_Vfs_object_return!=NULL,FALSE);
g_return_val_if_fail(corba_GLogFunc_object_return!=NULL,FALSE);
g_return_val_if_fail(parentheart_fds_1_return!=NULL,FALSE);
+ g_return_val_if_fail(child_pid_return!=NULL,FALSE);
errint=pipe(Vfs_IOR_fds);
g_return_val_if_fail(errint==0,FALSE);
if (child_captive_vfs_object->options.sandbox_server_ior) {
g_assert(child_captive_vfs_object->options.sandbox_server_argv==NULL);
*parentheart_fds_1_return=-1;
+ *child_pid_return=-1;
sandbox_parent(
child_captive_vfs_object->options.sandbox_server_ior, /* Vfs_IOR */
NULL, /* child_chroot_pid_hashkey_dir */
}
g_assert(child_captive_vfs_object->options.sandbox_server_argv!=NULL);
- switch (fork()) {
+ switch ((*child_pid_return=fork())) {
case -1: /* error */
g_return_val_if_reached(FALSE);
#ifdef ORBIT2 /* Prevent missing $(ORBIT_CFLAGS) outside of libcaptive/sandbox/ */
gboolean captive_sandbox_spawn(CaptiveVfsObject *child_captive_vfs_object,
Captive_Vfs *corba_Vfs_object_return,Captive_GLogFunc *corba_GLogFunc_object_return,
- Captive_CaptiveIOChannel *corba_CaptiveIOChannel_object_return,int *parentheart_fds_1_return);
+ Captive_CaptiveIOChannel *corba_CaptiveIOChannel_object_return,int *parentheart_fds_1_return,
+ pid_t *child_pid_return);
gboolean validate_CORBA_Environment(CORBA_Environment *evp);
GnomeVFSResult captive_sandbox_parent_return_from_CORBA_Environment(CORBA_Environment *evp);
void captive_sandbox_child_GnomeVFSResultException_throw(CORBA_Environment *evp,GnomeVFSResult errvfsresult);