@@ -19,9 +19,9 @@ use crate::sys::c;
19
19
use crate :: sys:: cvt;
20
20
use crate :: sys:: fs:: { File , OpenOptions } ;
21
21
use crate :: sys:: handle:: Handle ;
22
- use crate :: sys:: mutex:: Mutex ;
23
22
use crate :: sys:: pipe:: { self , AnonPipe } ;
24
23
use crate :: sys:: stdio;
24
+ use crate :: sys_common:: mutex:: StaticMutex ;
25
25
use crate :: sys_common:: process:: { CommandEnv , CommandEnvs } ;
26
26
use crate :: sys_common:: AsInner ;
27
27
@@ -94,10 +94,6 @@ pub struct StdioPipes {
94
94
pub stderr : Option < AnonPipe > ,
95
95
}
96
96
97
- struct DropGuard < ' a > {
98
- lock : & ' a Mutex ,
99
- }
100
-
101
97
impl Command {
102
98
pub fn new ( program : & OsStr ) -> Command {
103
99
Command {
@@ -209,8 +205,9 @@ impl Command {
209
205
//
210
206
// For more information, msdn also has an article about this race:
211
207
// http://support.microsoft.com/kb/315939
212
- static CREATE_PROCESS_LOCK : Mutex = Mutex :: new ( ) ;
213
- let _guard = DropGuard :: new ( & CREATE_PROCESS_LOCK ) ;
208
+ static CREATE_PROCESS_LOCK : StaticMutex = StaticMutex :: new ( ) ;
209
+
210
+ let _guard = unsafe { CREATE_PROCESS_LOCK . lock ( ) } ;
214
211
215
212
let mut pipes = StdioPipes { stdin : None , stdout : None , stderr : None } ;
216
213
let null = Stdio :: Null ;
@@ -259,23 +256,6 @@ impl fmt::Debug for Command {
259
256
}
260
257
}
261
258
262
- impl < ' a > DropGuard < ' a > {
263
- fn new ( lock : & ' a Mutex ) -> DropGuard < ' a > {
264
- unsafe {
265
- lock. lock ( ) ;
266
- DropGuard { lock }
267
- }
268
- }
269
- }
270
-
271
- impl < ' a > Drop for DropGuard < ' a > {
272
- fn drop ( & mut self ) {
273
- unsafe {
274
- self . lock . unlock ( ) ;
275
- }
276
- }
277
- }
278
-
279
259
impl Stdio {
280
260
fn to_handle ( & self , stdio_id : c:: DWORD , pipe : & mut Option < AnonPipe > ) -> io:: Result < Handle > {
281
261
match * self {
0 commit comments