From fcc8237add51afa8b075805c0d2693dd70cfbe5a Mon Sep 17 00:00:00 2001
From: Ossi Herrala <oherrala@iki.fi>
Date: Wed, 18 Oct 2017 13:48:31 +0300
Subject: [PATCH] Introduce pthread_cancel() for terminating threads
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

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.
---
 src/unix/bsd/mod.rs          | 1 +
 src/unix/notbsd/linux/mod.rs | 1 +
 2 files changed, 2 insertions(+)

diff --git a/src/unix/bsd/mod.rs b/src/unix/bsd/mod.rs
index ab256d1e..1a7d22ab 100644
--- a/src/unix/bsd/mod.rs
+++ b/src/unix/bsd/mod.rs
@@ -491,6 +491,7 @@ extern {
                            oldset: *mut sigset_t) -> ::c_int;
     pub fn sem_open(name: *const ::c_char, oflag: ::c_int, ...) -> *mut sem_t;
     pub fn getgrnam(name: *const ::c_char) -> *mut ::group;
+    pub fn pthread_cancel(thread: ::pthread_t) -> ::c_int;
     pub fn pthread_kill(thread: ::pthread_t, sig: ::c_int) -> ::c_int;
     pub fn sem_unlink(name: *const ::c_char) -> ::c_int;
     pub fn daemon(nochdir: ::c_int, noclose: ::c_int) -> ::c_int;
diff --git a/src/unix/notbsd/linux/mod.rs b/src/unix/notbsd/linux/mod.rs
index 0841dd2e..c88fe49c 100644
--- a/src/unix/notbsd/linux/mod.rs
+++ b/src/unix/notbsd/linux/mod.rs
@@ -1411,6 +1411,7 @@ extern {
                            oldset: *mut sigset_t) -> ::c_int;
     pub fn sem_open(name: *const ::c_char, oflag: ::c_int, ...) -> *mut sem_t;
     pub fn getgrnam(name: *const ::c_char) -> *mut ::group;
+    pub fn pthread_cancel(thread: ::pthread_t) -> ::c_int;
     pub fn pthread_kill(thread: ::pthread_t, sig: ::c_int) -> ::c_int;
     pub fn sem_unlink(name: *const ::c_char) -> ::c_int;
     pub fn daemon(nochdir: ::c_int, noclose: ::c_int) -> ::c_int;
-- 
GitLab