From: Daniel Fahlgren <daniel@fahlgren.se>
To: musl@lists.openwall.com
Subject: [musl] [PATCH] add support for pthread_sigqueue
Date: Wed, 05 Feb 2020 15:12:55 +0100 [thread overview]
Message-ID: <294c4c13f86c6f9ea3593309458bcb75a1d5d9e8.camel@fahlgren.se> (raw)
[-- Attachment #1: Type: text/plain, Size: 168 bytes --]
Hi,
This patch adds the function pthread_sigqueue. Since this is my first
patch to musl I probably have missed something. Any feedback?
Best regards,
Daniel Fahlgren
[-- Attachment #2: 0001-Add-pthread_sigqueue.patch --]
[-- Type: text/x-patch, Size: 1625 bytes --]
From 2e3e423b4d3d62fec3525c2e09fc9daf35fbe885 Mon Sep 17 00:00:00 2001
From: Daniel Fahlgren <daniel@fahlgren.se>
Date: Wed, 5 Feb 2020 13:24:43 +0100
Subject: [PATCH] Add pthread_sigqueue
This makes it possible to queue a signal and data to a thread
---
include/signal.h | 1 +
src/thread/pthread_sigqueue.c | 24 ++++++++++++++++++++++++
2 files changed, 25 insertions(+)
create mode 100644 src/thread/pthread_sigqueue.c
diff --git a/include/signal.h b/include/signal.h
index fbdf667b..8bb7d1b4 100644
--- a/include/signal.h
+++ b/include/signal.h
@@ -214,6 +214,7 @@ int sigqueue(pid_t, int, union sigval);
int pthread_sigmask(int, const sigset_t *__restrict, sigset_t *__restrict);
int pthread_kill(pthread_t, int);
+int pthread_sigqueue(pthread_t, int, union sigval);
void psiginfo(const siginfo_t *, const char *);
void psignal(int, const char *);
diff --git a/src/thread/pthread_sigqueue.c b/src/thread/pthread_sigqueue.c
new file mode 100644
index 00000000..8de8d49a
--- /dev/null
+++ b/src/thread/pthread_sigqueue.c
@@ -0,0 +1,23 @@
+#include <signal.h>
+#include <string.h>
+#include <unistd.h>
+#include "pthread_impl.h"
+#include "lock.h"
+
+int pthread_sigqueue(pthread_t t, int sig, const union sigval value)
+{
+ siginfo_t si;
+ sigset_t set;
+ int r;
+ memset(&si, 0, sizeof si);
+ si.si_signo = sig;
+ si.si_code = SI_QUEUE;
+ si.si_value = value;
+ si.si_uid = getuid();
+ si.si_pid = getpid();
+ LOCK(t->killlock);
+ r = t->tid ? -__syscall(SYS_rt_tgsigqueueinfo, si.si_pid, t->tid, sig, &si)
+ : (sig+0U >= _NSIG ? EINVAL : 0);
+ UNLOCK(t->killlock);
+ return r;
+}
--
2.17.1
next reply other threads:[~2020-02-05 14:13 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-02-05 14:12 Daniel Fahlgren [this message]
2020-02-05 19:27 ` Rich Felker
2020-02-05 23:06 ` A. Wilcox
2020-02-06 0:17 ` Rich Felker
2020-02-06 1:12 ` A. Wilcox
2020-02-05 23:08 ` Daniel Fahlgren
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=294c4c13f86c6f9ea3593309458bcb75a1d5d9e8.camel@fahlgren.se \
--to=daniel@fahlgren.se \
--cc=musl@lists.openwall.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.vuxu.org/mirror/musl/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).