@@ -13,7 +13,7 @@ use libc;
1313use mem;
1414use ptr;
1515
16- use sys:: process:: magenta:: { Handle , launchpad_t , mx_handle_t} ;
16+ use sys:: process:: magenta:: { Handle , mx_handle_t} ;
1717use sys:: process:: process_common:: * ;
1818
1919////////////////////////////////////////////////////////////////////////////////
@@ -30,9 +30,9 @@ impl Command {
3030
3131 let ( ours, theirs) = self . setup_io ( default, needs_stdin) ?;
3232
33- let ( launchpad , process_handle) = unsafe { self . do_exec ( theirs) ? } ;
33+ let process_handle = unsafe { self . do_exec ( theirs) ? } ;
3434
35- Ok ( ( Process { launchpad : launchpad , handle : Handle :: new ( process_handle) } , ours) )
35+ Ok ( ( Process { handle : Handle :: new ( process_handle) } , ours) )
3636 }
3737
3838 pub fn exec ( & mut self , default : Stdio ) -> io:: Error {
@@ -51,7 +51,7 @@ impl Command {
5151 }
5252
5353 unsafe fn do_exec ( & mut self , stdio : ChildPipes )
54- -> io:: Result < ( * mut launchpad_t , mx_handle_t ) > {
54+ -> io:: Result < mx_handle_t > {
5555 use sys:: process:: magenta:: * ;
5656
5757 let job_handle = mx_job_default ( ) ;
@@ -75,16 +75,15 @@ impl Command {
7575 let launchpad_destructor = LaunchpadDestructor ( launchpad) ;
7676
7777 // Set the process argv
78- mx_cvt ( launchpad_arguments ( launchpad, self . get_argv ( ) . len ( ) as i32 - 1 ,
79- self . get_argv ( ) . as_ptr ( ) ) ) ?;
78+ mx_cvt ( launchpad_set_args ( launchpad, self . get_argv ( ) . len ( ) as i32 - 1 ,
79+ self . get_argv ( ) . as_ptr ( ) ) ) ?;
8080 // Setup the environment vars
81- mx_cvt ( launchpad_environ ( launchpad, envp) ) ?;
81+ mx_cvt ( launchpad_set_environ ( launchpad, envp) ) ?;
8282 mx_cvt ( launchpad_add_vdso_vmo ( launchpad) ) ?;
83- mx_cvt ( launchpad_clone_mxio_root ( launchpad) ) ?;
8483 // Load the executable
8584 mx_cvt ( launchpad_elf_load ( launchpad, launchpad_vmo_from_file ( self . get_argv ( ) [ 0 ] ) ) ) ?;
8685 mx_cvt ( launchpad_load_vdso ( launchpad, MX_HANDLE_INVALID ) ) ?;
87- mx_cvt ( launchpad_clone_mxio_cwd ( launchpad) ) ?;
86+ mx_cvt ( launchpad_clone ( launchpad, LP_CLONE_MXIO_ROOT | LP_CLONE_MXIO_CWD ) ) ?;
8887
8988 // Clone stdin, stdout, and stderr
9089 if let Some ( fd) = stdio. stdin . fd ( ) {
@@ -111,12 +110,15 @@ impl Command {
111110 callback ( ) ?;
112111 }
113112
114- let process_handle = mx_cvt ( launchpad_start ( launchpad) ) ?;
115-
116- // Successfully started the launchpad
113+ // `launchpad_go` destroys the launchpad, so we must not
117114 mem:: forget ( launchpad_destructor) ;
118115
119- Ok ( ( launchpad, process_handle) )
116+ let mut process_handle: mx_handle_t = 0 ;
117+ let mut err_msg: * const libc:: c_char = ptr:: null ( ) ;
118+ mx_cvt ( launchpad_go ( launchpad, & mut process_handle, & mut err_msg) ) ?;
119+ // FIXME: See if we want to do something with that err_msg
120+
121+ Ok ( process_handle)
120122 }
121123}
122124
@@ -125,7 +127,6 @@ impl Command {
125127////////////////////////////////////////////////////////////////////////////////
126128
127129pub struct Process {
128- launchpad : * mut launchpad_t ,
129130 handle : Handle ,
130131}
131132
@@ -195,10 +196,3 @@ impl Process {
195196 Ok ( Some ( ExitStatus :: new ( proc_info. rec . return_code ) ) )
196197 }
197198}
198-
199- impl Drop for Process {
200- fn drop ( & mut self ) {
201- use sys:: process:: magenta:: launchpad_destroy;
202- unsafe { launchpad_destroy ( self . launchpad ) ; }
203- }
204- }
0 commit comments