We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 802d475 commit 6441d61Copy full SHA for 6441d61
src/libcore/os.rs
@@ -452,10 +452,19 @@ pub fn self_exe_path() -> Option<Path> {
452
fn load_self() -> Option<~str> {
453
unsafe {
454
use libc::funcs::posix01::unistd::readlink;
455
- do fill_charp_buf() |buf, sz| {
+
456
+ let mut path_str = str::with_capacity(tmpbuf_sz);
457
+ let len = do str::as_c_str(path_str) |buf| {
458
+ let buf = buf as *mut c_char;
459
do as_c_charp("/proc/self/exe") |proc_self_buf| {
- readlink(proc_self_buf, buf, sz) != (-1 as ssize_t)
460
+ readlink(proc_self_buf, buf, tmpbuf_sz as size_t)
461
}
462
+ };
463
+ if len == -1 {
464
+ None
465
+ } else {
466
+ str::raw::set_len(&mut path_str, len as uint);
467
+ Some(path_str)
468
469
470
0 commit comments