File tree 1 file changed +17
-13
lines changed 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> {
380
380
381
381
#[ cfg( any( target_os = "solaris" , target_os = "illumos" ) ) ]
382
382
pub 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) ) ;
393
396
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
+ }
397
401
}
398
402
}
399
403
}
You can’t perform that action at this time.
0 commit comments