@@ -19,9 +19,9 @@ use crate::sys::c;
1919use crate :: sys:: cvt;
2020use crate :: sys:: fs:: { File , OpenOptions } ;
2121use crate :: sys:: handle:: Handle ;
22- use crate :: sys:: mutex:: Mutex ;
2322use crate :: sys:: pipe:: { self , AnonPipe } ;
2423use crate :: sys:: stdio;
24+ use crate :: sys_common:: mutex:: StaticMutex ;
2525use crate :: sys_common:: process:: { CommandEnv , CommandEnvs } ;
2626use crate :: sys_common:: AsInner ;
2727
@@ -94,10 +94,6 @@ pub struct StdioPipes {
9494 pub stderr : Option < AnonPipe > ,
9595}
9696
97- struct DropGuard < ' a > {
98- lock : & ' a Mutex ,
99- }
100-
10197impl Command {
10298 pub fn new ( program : & OsStr ) -> Command {
10399 Command {
@@ -209,8 +205,9 @@ impl Command {
209205 //
210206 // For more information, msdn also has an article about this race:
211207 // 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 ( ) } ;
214211
215212 let mut pipes = StdioPipes { stdin : None , stdout : None , stderr : None } ;
216213 let null = Stdio :: Null ;
@@ -259,23 +256,6 @@ impl fmt::Debug for Command {
259256 }
260257}
261258
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-
279259impl Stdio {
280260 fn to_handle ( & self , stdio_id : c:: DWORD , pipe : & mut Option < AnonPipe > ) -> io:: Result < Handle > {
281261 match * self {
0 commit comments