File tree Expand file tree Collapse file tree 1 file changed +17
-13
lines changed Expand file tree Collapse file tree 1 file changed +17
-13
lines changed Original file line number Diff line number Diff line change @@ -380,20 +380,24 @@ pub fn current_exe() -> io::Result<PathBuf> {
380380
381381#[ cfg( any( target_os = "solaris" ,  target_os = "illumos" ) ) ]  
382382pub  fn  current_exe ( )  -> io:: Result < PathBuf >  { 
383-     extern  "C"  { 
384-         fn  getexecname ( )  -> * const  c_char ; 
385-     } 
386-     unsafe  { 
387-         let  path = getexecname ( ) ; 
388-         if  path. is_null ( )  { 
389-             Err ( io:: Error :: last_os_error ( ) ) 
390-         }  else  { 
391-             let  filename = CStr :: from_ptr ( path) . to_bytes ( ) ; 
392-             let  path = PathBuf :: from ( <OsStr  as  OsStrExt >:: from_bytes ( filename) ) ; 
383+     if  let  Ok ( path)  = crate :: fs:: read_link ( "/proc/self/path/a.out" )  { 
384+         Ok ( path) 
385+     }  else  { 
386+         extern  "C"  { 
387+             fn  getexecname ( )  -> * const  c_char ; 
388+         } 
389+         unsafe  { 
390+             let  path = getexecname ( ) ; 
391+             if  path. is_null ( )  { 
392+                 Err ( io:: Error :: last_os_error ( ) ) 
393+             }  else  { 
394+                 let  filename = CStr :: from_ptr ( path) . to_bytes ( ) ; 
395+                 let  path = PathBuf :: from ( <OsStr  as  OsStrExt >:: from_bytes ( filename) ) ; 
393396
394-             // Prepend a current working directory to the path if 
395-             // it doesn't contain an absolute pathname. 
396-             if  filename[ 0 ]  == b'/'  {  Ok ( path)  }  else  {  getcwd ( ) . map ( |cwd| cwd. join ( path) )  } 
397+                 // Prepend a current working directory to the path if 
398+                 // it doesn't contain an absolute pathname. 
399+                 if  filename[ 0 ]  == b'/'  {  Ok ( path)  }  else  {  getcwd ( ) . map ( |cwd| cwd. join ( path) )  } 
400+             } 
397401        } 
398402    } 
399403} 
    
 
   
 
     
   
   
          
     
  
    
     
 
    
      
     
 
     
    You can’t perform that action at this time.
  
 
    
  
     
    
      
        
     
 
       
      
     
   
 
    
    
  
 
  
 
     
    
0 commit comments