@@ -13,7 +13,7 @@ use libc;
13
13
use mem;
14
14
use ptr;
15
15
16
- use sys:: process:: magenta:: { Handle , launchpad_t , mx_handle_t} ;
16
+ use sys:: process:: magenta:: { Handle , mx_handle_t} ;
17
17
use sys:: process:: process_common:: * ;
18
18
19
19
////////////////////////////////////////////////////////////////////////////////
@@ -30,9 +30,9 @@ impl Command {
30
30
31
31
let ( ours, theirs) = self . setup_io ( default, needs_stdin) ?;
32
32
33
- let ( launchpad , process_handle) = unsafe { self . do_exec ( theirs) ? } ;
33
+ let process_handle = unsafe { self . do_exec ( theirs) ? } ;
34
34
35
- Ok ( ( Process { launchpad : launchpad , handle : Handle :: new ( process_handle) } , ours) )
35
+ Ok ( ( Process { handle : Handle :: new ( process_handle) } , ours) )
36
36
}
37
37
38
38
pub fn exec ( & mut self , default : Stdio ) -> io:: Error {
@@ -51,7 +51,7 @@ impl Command {
51
51
}
52
52
53
53
unsafe fn do_exec ( & mut self , stdio : ChildPipes )
54
- -> io:: Result < ( * mut launchpad_t , mx_handle_t ) > {
54
+ -> io:: Result < mx_handle_t > {
55
55
use sys:: process:: magenta:: * ;
56
56
57
57
let job_handle = mx_job_default ( ) ;
@@ -75,16 +75,15 @@ impl Command {
75
75
let launchpad_destructor = LaunchpadDestructor ( launchpad) ;
76
76
77
77
// 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 ( ) ) ) ?;
80
80
// Setup the environment vars
81
- mx_cvt ( launchpad_environ ( launchpad, envp) ) ?;
81
+ mx_cvt ( launchpad_set_environ ( launchpad, envp) ) ?;
82
82
mx_cvt ( launchpad_add_vdso_vmo ( launchpad) ) ?;
83
- mx_cvt ( launchpad_clone_mxio_root ( launchpad) ) ?;
84
83
// Load the executable
85
84
mx_cvt ( launchpad_elf_load ( launchpad, launchpad_vmo_from_file ( self . get_argv ( ) [ 0 ] ) ) ) ?;
86
85
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 ) ) ?;
88
87
89
88
// Clone stdin, stdout, and stderr
90
89
if let Some ( fd) = stdio. stdin . fd ( ) {
@@ -111,12 +110,15 @@ impl Command {
111
110
callback ( ) ?;
112
111
}
113
112
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
117
114
mem:: forget ( launchpad_destructor) ;
118
115
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)
120
122
}
121
123
}
122
124
@@ -125,7 +127,6 @@ impl Command {
125
127
////////////////////////////////////////////////////////////////////////////////
126
128
127
129
pub struct Process {
128
- launchpad : * mut launchpad_t ,
129
130
handle : Handle ,
130
131
}
131
132
@@ -195,10 +196,3 @@ impl Process {
195
196
Ok ( Some ( ExitStatus :: new ( proc_info. rec . return_code ) ) )
196
197
}
197
198
}
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