Skip to content

Commit fda4049

Browse files
committed
Auto merge of rust-lang#596 - Susurrus:master, r=alexcrichton
Use NOCANCEL variants for close on Mac The default `close()` on OS X does not provide clear errors, instead the `$NOCANCEL` variants should be used. These are available as of OS X 10.6 onwards. Fixes rust-lang#595.
2 parents 7db3fd5 + 9b9f36a commit fda4049

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

libc-test/build.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -504,7 +504,7 @@ fn main() {
504504
"backtrace" |
505505
"sysinfo" | "newlocale" | "duplocale" | "freelocale" | "uselocale" |
506506
"nl_langinfo_l" | "wcslen" | "wcstombs" if uclibc => true,
507-
507+
508508
// Apparently res_init exists on Android, but isn't defined in a header:
509509
// https://mail.gnome.org/archives/commits-list/2013-May/msg01329.html
510510
"res_init" if android => true,
@@ -515,6 +515,9 @@ fn main() {
515515
// https://github.com/rust-lang/libc/pull/585#discussion_r114561460
516516
"res_init" if apple => true,
517517

518+
// On Mac we don't use the default `close()`, instead using their $NOCANCEL variants.
519+
"close" if apple => true,
520+
518521
_ => false,
519522
}
520523
});

src/unix/mod.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -405,7 +405,9 @@ extern {
405405
pub fn lchown(path: *const c_char, uid: uid_t,
406406
gid: gid_t) -> ::c_int;
407407
#[cfg_attr(all(target_os = "macos", target_arch = "x86"),
408-
link_name = "close$UNIX2003")]
408+
link_name = "close$NOCANCEL$UNIX2003")]
409+
#[cfg_attr(all(target_os = "macos", target_arch = "x86_64"),
410+
link_name = "close$NOCANCEL")]
409411
pub fn close(fd: ::c_int) -> ::c_int;
410412
pub fn dup(fd: ::c_int) -> ::c_int;
411413
pub fn dup2(src: ::c_int, dst: ::c_int) -> ::c_int;

0 commit comments

Comments
 (0)