Skip to content

Commit 07088d2

Browse files
committed
Auto merge of rust-lang#810 - oherrala:pthread_cancel, r=alexcrichton
Introduce pthread_cancel() for terminating threads pthread_cancel() is safer way to terminate thread than pthread_kill(). This function can be found from ISO/IEC 9945-1:1996 (“POSIX.1”) and first introduced into Single Unix Specification version 2 on 1997.
2 parents 2172bb4 + f024fe7 commit 07088d2

File tree

2 files changed

+4
-0
lines changed

2 files changed

+4
-0
lines changed

src/unix/bsd/mod.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -491,6 +491,9 @@ extern {
491491
oldset: *mut sigset_t) -> ::c_int;
492492
pub fn sem_open(name: *const ::c_char, oflag: ::c_int, ...) -> *mut sem_t;
493493
pub fn getgrnam(name: *const ::c_char) -> *mut ::group;
494+
#[cfg_attr(all(target_os = "macos", target_arch = "x86"),
495+
link_name = "pthread_cancel$UNIX2003")]
496+
pub fn pthread_cancel(thread: ::pthread_t) -> ::c_int;
494497
pub fn pthread_kill(thread: ::pthread_t, sig: ::c_int) -> ::c_int;
495498
pub fn sem_unlink(name: *const ::c_char) -> ::c_int;
496499
pub fn daemon(nochdir: ::c_int, noclose: ::c_int) -> ::c_int;

src/unix/notbsd/linux/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1411,6 +1411,7 @@ extern {
14111411
oldset: *mut sigset_t) -> ::c_int;
14121412
pub fn sem_open(name: *const ::c_char, oflag: ::c_int, ...) -> *mut sem_t;
14131413
pub fn getgrnam(name: *const ::c_char) -> *mut ::group;
1414+
pub fn pthread_cancel(thread: ::pthread_t) -> ::c_int;
14141415
pub fn pthread_kill(thread: ::pthread_t, sig: ::c_int) -> ::c_int;
14151416
pub fn sem_unlink(name: *const ::c_char) -> ::c_int;
14161417
pub fn daemon(nochdir: ::c_int, noclose: ::c_int) -> ::c_int;

0 commit comments

Comments
 (0)