2 * CORBA/ORBit client side of Vfs object of sandbox_parent()
3 * Copyright (C) 2003 Jan Kratochvil <project-captive@jankratochvil.net>
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; exactly version 2 of June 1991 is required
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22 #include "captive/parent-Vfs.h" /* self */
23 #include <glib/gmessages.h>
25 #include "../client/vfs.h"
28 #include "server-GLogFunc.h"
29 #include "server-CaptiveIOChannel.h"
30 #include <signal.h> /* for kill(2) */
34 GnomeVFSResult captive_sandbox_parent_vfs_new(CaptiveVfsObject *captive_vfs_object)
38 g_return_val_if_fail(captive_vfs_object!=NULL,GNOME_VFS_ERROR_BAD_PARAMETERS);
40 captive_vfs_object->is_sandbox_parent=TRUE;
42 errbool=captive_sandbox_spawn(
43 captive_vfs_object, /* child_captive_vfs_object */
44 &captive_vfs_object->corba_Vfs_object, /* corba_Vfs_object_return */
45 &captive_vfs_object->corba_GLogFunc_object, /* corba_GLogFunc_object_return */
46 &captive_vfs_object->corba_CaptiveIOChannel_object, /* corba_CaptiveIOChannel_object_return */
47 &captive_vfs_object->corba_parent_giochanel_blind, /* corba_parent_giochanel_blind_ptr */
48 &captive_vfs_object->corba_parentheart_fds_1, /* parentheart_fds_1_return */
49 &captive_vfs_object->corba_child_pid); /* child_pid_return */
50 g_return_val_if_fail(errbool==TRUE,GNOME_VFS_ERROR_GENERIC);
56 GnomeVFSResult captive_sandbox_parent_vfs_close(CaptiveVfsObject *captive_vfs_object)
60 impl_POA_Captive_GLogFunc *GLogFunc_servant;
61 impl_POA_Captive_CaptiveIOChannel *CaptiveIOChannel_servant;
62 GIOStatus erriostatus;
64 g_return_val_if_fail(captive_vfs_object!=NULL,GNOME_VFS_ERROR_BAD_PARAMETERS);
66 Captive_Vfs_shutdown(captive_vfs_object->corba_Vfs_object,&captive_corba_ev);
67 r=captive_sandbox_parent_return_from_CORBA_Environment(&captive_corba_ev);
69 CORBA_Object_release(captive_vfs_object->corba_Vfs_object,&captive_corba_ev);
70 g_assert(validate_CORBA_Environment(&captive_corba_ev));
72 /* Shutdown 'GLogFunc' servant. */
73 GLogFunc_servant=PortableServer_POA_reference_to_servant(captive_corba_poa,
74 captive_vfs_object->corba_GLogFunc_object,&captive_corba_ev);
75 g_assert(validate_CORBA_Environment(&captive_corba_ev));
76 CORBA_Object_release(captive_vfs_object->corba_GLogFunc_object,&captive_corba_ev);
77 g_assert(validate_CORBA_Environment(&captive_corba_ev));
78 impl_Captive_GLogFunc__destroy(GLogFunc_servant,&captive_corba_ev);
79 g_assert(validate_CORBA_Environment(&captive_corba_ev));
81 /* Shutdown 'CaptiveIOChannel' servant. */
82 CaptiveIOChannel_servant=PortableServer_POA_reference_to_servant(captive_corba_poa,
83 captive_vfs_object->corba_CaptiveIOChannel_object,&captive_corba_ev);
84 g_assert(validate_CORBA_Environment(&captive_corba_ev));
85 CORBA_Object_release(captive_vfs_object->corba_CaptiveIOChannel_object,&captive_corba_ev);
86 g_assert(validate_CORBA_Environment(&captive_corba_ev));
87 impl_Captive_CaptiveIOChannel__destroy(CaptiveIOChannel_servant,&captive_corba_ev);
88 g_assert(validate_CORBA_Environment(&captive_corba_ev));
89 erriostatus=g_io_channel_flush(
90 captive_vfs_object->corba_parent_giochanel_blind, /* channel */
92 g_assert(erriostatus==G_IO_STATUS_NORMAL);
94 g_io_channel_unref(captive_vfs_object->corba_parent_giochanel_blind);
97 /* Close parentheart_fd_write. */
98 if (captive_vfs_object->corba_parentheart_fds_1!=-1) {
99 errint=close(captive_vfs_object->corba_parentheart_fds_1);
100 g_return_val_if_fail(errint==0,FALSE);
103 /* Cleanup the child process. */
104 if (captive_vfs_object->corba_child_pid!=(pid_t)-1) {
111 kill(captive_vfs_object->corba_child_pid,SIGKILL); /* errors ignored */
115 waitpid(captive_vfs_object->corba_child_pid,
117 WNOHANG); /* options */